Hi Anton>> $ g++ -g tut1.cpp `llvm-config --cxxflags --ldflags --libs core` -o tut1 >> /mingw/lib/libLLVMSystem.a(Process.o):Process.cpp:(.text+0x8d): >> undefined reference to `GetProcessMemoryInfo at 12' >> collect2: ld returned 1 exit status > I believe you will need additional libraries like imagehlp and psapi.I have /lib/libimagehlp.a and /lib/libpsapi.a nm --defined-only /lib/libpsapi.a | grep "GetProcessMemoryInfo" - returns: 00000000 T _GetProcessMemoryInfo at 12 00000000 I __imp__GetProcessMemoryInfo at 12 And llvm-config seems to be asking for them to be picked up: -I//include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2 -fomit-frame-pointer -Woverloaded-virtual -L//lib -lpsapi -limagehlp -lm -lLLVMCore -lLLVMSupport -lLLVMSystem So I'm still mystified. Best regards, Duncan
Duncan Pierce <duncan at duncanpierce.org> writes:> I have /lib/libimagehlp.a and /lib/libpsapi.a > > nm --defined-only /lib/libpsapi.a | grep "GetProcessMemoryInfo" - > > returns: > > 00000000 T _GetProcessMemoryInfo at 12 > 00000000 I __imp__GetProcessMemoryInfo at 12 > > And llvm-config seems to be asking for them to be picked up: > > -I//include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2 > -fomit-frame-pointer -Woverloaded-virtual > -L//lib -lpsapi -limagehlp -lm > -lLLVMCore -lLLVMSupport -lLLVMSystem > > So I'm still mystified.Put them at the end of the library list: -lLLVMCore -lLLVMSupport -lLLVMSystem -limagehlp -lpsapi -lm Unless recently changed, mingw's ld resolves symbols sequentially on the library list, it does not look on previously processed libraries, so order is relevant. If llvm-config puts psapi and imagehlp at the beginning of the list, that probably is a bug on llvm-config. But llvm-config's source code does not mention psapi and/or imagehlp at all. Are you sure that -lpsapi and -limagehlp are on the output of llvm-config? They are not on my mingw's LLVM, although it is several weeks old. -- Oscar
Duncan Pierce
2009-Jan-18 12:58 UTC
[LLVMdev] Build problems on MinGW solved - possible llvm-config bug
Óscar Fuentes <ofv <at> wanadoo.es> writes:> Duncan Pierce <duncan <at> duncanpierce.org> writes: > > > I have /lib/libimagehlp.a and /lib/libpsapi.a > > And llvm-config seems to be asking for them to be picked up: > > > > -I//include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2 > > -fomit-frame-pointer -Woverloaded-virtual > > -L//lib -lpsapi -limagehlp -lm > > -lLLVMCore -lLLVMSupport -lLLVMSystem > > > > So I'm still mystified. > > Put them at the end of the library list: > > -lLLVMCore -lLLVMSupport -lLLVMSystem -limagehlp -lpsapi -lmThis works. I had a look at changing the llvm-config.in.in but my Perl hacking skills aren't up to getting --libnames and --libfiles to work as well as --libs. I discovered one other thing that was causing me problems on MinGW: if I use the msys.bat to open a terminal llvm-config inserts double slashes at the start of any absolute path it generates (e.g. //lib/LLVMX86CodeGen.o) - this breaks g++. If I do the same thing from a DOS prompt running bash, slashes don't get doubled and everything works fine. Thanks once again Óscar and Anton. Duncan Pierce