[Darshan-users] Darshan undefined compilation error

Shane Snyder ssnyder at mcs.anl.gov
Tue Oct 24 11:24:48 CDT 2017

I'm confirming the same type of behavior you are seeing when using both 
the Darshan generated compiler wrapper as well as the MPICH profiling 
hooks. In my MPICH build, I did not set any specific flags to enable or 
disable shared/static libs, so MPICH will prefer dynamic libs by default 
(at least on my laptop).

In the case of using Darshan generated compiler wrappers, they actually 
back out and do not insert any Darshan link flags when using dynamic 
linking, so this is expected behavior.

In the case of the profiling configuration method, the linking is again 
thrown off by the use of dynamic MPICH libs which causes the undefined 
reference errors you are seeing.

As for possible workarounds, you have a couple of options:

1.) Just keep using your current MPICH build, but use the LD_PRELOAD 
method for instrumentation that works with dynamic executables. You just 
need to export LD_PRELOAD to point at your libdarshan.so before running 
your application (which you just compile using MPICH's stock mpicc).

2.) As I mentioned in the previous email, you could rebuild MPICH to 
disable shared libs and only build static libs. After that, either of 
the above static linking methods should work.


On 10/24/2017 10:06 AM, Shane Snyder wrote:
> Hi Adnan,
> Do you get the same types of errors (undefined reference to 
> __wrap_fprintf, etc.) when using the MPI profile configuration method 
> (that is, exporting MPICXX_PROFILE)?
> Let's troubleshoot that method first since it looks like you are 
> getting further along with it. It at least seems to have the link line 
> right, at first glance.
> FWIW, we typically "encourage" users to configure MPICH libraries to 
> be built corresponding to the link method they want to use. So, in 
> your case (static linking), it might simplify things to configure 
> MPICH to only build its static libraries (using '--enable-static 
> --disable-shared' on the configure line). That's not to say we can't 
> get the static linking working using default configure options, just 
> appears to be more difficult to get right. I can try playing around 
> with my local MPICH build and darshan builds to see if I can get it 
> working, and will let you know how if I do.
> Thanks,
> --Shane
> On 10/18/2017 06:10 PM, Adnan Haider wrote:
>> I have been trying the mpicxx -profile=/path/to/mpicxx-cxx.conf 
>> option since I have gotten further with this method, but here is the 
>> output for both:
>> when using mpicxx.darshan method:
>> g++ -o binary *.o darshan/simple.cc 
>> -I/home/adhaider/apps/mpich_install/include 
>> -L/home/adhaider/apps/mpich_install/lib -lmpicxx -Wl,-rpath 
>> -Wl,/home/adhaider/apps/mpich_install/lib -Wl, --enable-new-dtags -lmpi
>> * notice the above doesn't even have the darshan libs.
>> Now when using mpicxx -profile=/path/to/conf
>> g++ -o binary *.o darshan/simple.cc 
>> -I/home/adhaider/apps/mpich_install/include 
>> -L/home/adhaider/apps/mpich_install/lib -lmpicxx -lmpicxx 
>> -L/home/adhaider/apps/darshan_install/lib -ldarshan -lz 
>> -Wl,@/home/adhaider/apps/darshan_install/share/ld-opts/darshan-base-ld-opts 
>> -Wl,-rpath -Wl,/home/adhaider/apps/mpich_install/lib 
>> -Wl,--enable-new-dtags -lmpi 
>> -L/home/adhaider/apps/darshan_install/lib -Wl,--start-group -ldarshan 
>> -ldarshan-stubs -Wl,--end-group -lz -lrt -lpthread
>> Thanks in advance!
>> Thanks, Adnan Haider
>> B.S Candidate, Computer Science
>> Illinois Institute of Technology
>> www.adnanhaider.com <http://www.adnanhaider.com>
>> On Wed, Oct 18, 2017 at 6:19 PM, Harms, Kevin <harms at alcf.anl.gov 
>> <mailto:harms at alcf.anl.gov>> wrote:
>>       Can you provide the output of the linking stage with the
>>     generated mpicc. So if you named your mpicc, mpicc.darshan:
>>       mpicc.darshan -show -o binary *.o
>>       The previous post you mentioned has some type of error in the
>>     generated script where one of the compiler arguments was not
>>     being added properly.
>>     kevin
>>     ________________________________________
>>     From: Darshan-users <darshan-users-bounces at lists.mcs.anl.gov
>>     <mailto:darshan-users-bounces at lists.mcs.anl.gov>> on behalf of
>>     Adnan Haider <ahaider3 at hawk.iit.edu <mailto:ahaider3 at hawk.iit.edu>>
>>     Sent: Wednesday, October 18, 2017 4:28:23 PM
>>     To: darshan-users at lists.mcs.anl.gov
>>     <mailto:darshan-users at lists.mcs.anl.gov>
>>     Subject: [Darshan-users] Darshan undefined compilation error
>>     Hi,
>>     I am trying to statically instrument my application with darshan.
>>     I am using mpich 3.2 and darshan 3.1.4. I have also tried 3.1.3
>>     and 3.0.0 all which give the same errors as this post:
>>     https://lists.mcs.anl.gov/mailman/htdig/darshan-users/2017-July/000448.html
>>     <https://lists.mcs.anl.gov/mailman/htdig/darshan-users/2017-July/000448.html>
>>     Maybe I am not compiling mpich with the correct flags? ( I am not
>>     changing the defaults).
>>     I get these errors for the example IO_simple.c as well as a very
>>     simple piece of MPI code.
>>     Also nm libdarshan.a does show the functions that are coming up
>>     as undefined, same as the post I linked to.
>>     Any help would be greatly appreciated.
>> _______________________________________________
>> Darshan-users mailing list
>> Darshan-users at lists.mcs.anl.gov
>> https://lists.mcs.anl.gov/mailman/listinfo/darshan-users
> _______________________________________________
> Darshan-users mailing list
> Darshan-users at lists.mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/darshan-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-users/attachments/20171024/45f9a158/attachment.html>

More information about the Darshan-users mailing list