Eclipse linker not finding my libraries - eclipse

I am having problems getting NSight Eclipse to link in my libraries:
Building target: SA_V1
Invoking: NVCC Linker
nvcc -L/home/streaming/VidApp_V1.0/src/AudioPreconditioning6Ch/dist/Release/GNU-Linux-x86 -L/home/streaming/cuda-workspace/libConfig/Debug -L/usr/lib32 -link -o "SA_V1" ./V1.1/DeckLinkAPIDispatch.o ./V1.1/DeckLinkAPIDispatch_v7_6.o ./V1.1/audio.o ./V1.1/capture.o ./V1.1/cudaEngine.o ./V1.1/decklink.o ./V1.1/engine.o ./V1.1/filter.o ./V1.1/filterKernel.o ./V1.1/initialize.o ./V1.1/main.o ./V1.1/playback.o ./V1.1/utils.o ./V1.1/videoFuncThread.o ./V1.1/vif.o ./V1.1/vof.o -llibAudioPreconditioning6Ch.so -lliblibConfig.so -llibtiff.so.4.3.2
/usr/bin/ld: cannot find -llibAudioPreconditioning6Ch.so
==> searching for the library I get:
/home/streaming/VidApp_V1.0/src/AudioPreconditioning6Ch/dist/Debug/GNU-Linux-x86/libAudioPreconditioning6Ch.so
/home/streaming/VidApp_V1.0/src/AudioPreconditioning6Ch/dist/Release/GNU-Linux-x86/libAudioPreconditioning6Ch.so
/home/streaming/dist/lib64/libAudioPreconditioning6Ch.so
What am I doing wrong?

Library names in Linux are not the same as in Windows. in VS, i was linking libConfig.lib, so when eclipse asked for the name of the library i typed in: liblibConfig.so which is the name of the file. Uh uh. In Linux the prefix lib is understood as a prefix and the suffix .so is also not part of the name. so entering: libConfig as the library to load (which gets inserted into make as: -llibConfig) solves the problem

Related

How to link Armadillo with Eclipse

I want to use Armadillo with Eclipse. However all the instructions to link Armadillo is given for Visual Studio. Now I followed the instructions outlined in the ReadMe file of the Armadillo library. I added the Armadillo include folder in project(right click)->properties->C/C++ Build->Settings->Cross G++ Compiler->Includes->Inlcude paths(-I) and then I added the libraries folder (The library folder contain lapack and blas .lib and .dll files) in project(right click)->properties->C/C++ Build->Settings->Cross G++ Linker->Libraries->Library search path (-L).
However when I compile the code in the Eclipse I get the error
.....armadillo_bits/lapack_wrapper.hpp:37: undefined reference to `dgetrf_'.
Shouldn't it simply search for .lib files in the library folder and include them during compiling? I would appreciate any help regarding this matter.
Regards,
TM
Linking the Armadillo library to an Eclipse project can be done and you were about to do it ! It's pretty much the same as for any other library.
In the properties of the project :
GCC C++ Compiler -> Includes : add the path to the file armadillo (where namespace arma is declared) to the include search path (option -I). Example : /home/alpha/soft/armadillo-4.400.1/include
GCC C++ Linker -> Libraries : add the path to the file libarmadillo.so... in the library search path (option -L) Example : /home/alpha/soft/armadillo-4.400.1 . Add armadillo, lapack, blas and m as libraries (option -l). m is for math.
Here are the calls to the compiler and the linker as produced by eclipse :
make all
Building file: ../src/armaeclip.cpp
Invoking: GCC C++ Compiler
g++ -I/home/alpha/soft/armadillo-4.100.1/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/armaeclip.d" -MT"src/armaeclip.d" -o "src/armaeclip.o" "../src/armaeclip.cpp"
Finished building: ../src/armaeclip.cpp
Building target: armaeclip
Invoking: GCC C++ Linker
g++ -L/home/alpha/soft/armadillo-4.100.1 -o "armaeclip" ./src/armaeclip.o -larmadillo -lblas -lm -llapack
Finished building target: armaeclip
**** Build Finished ****
As you run the code, you might get something like :
error: det(): use of ATLAS or LAPACK needs to be enabled
terminate called after throwing an instance of 'std::logic_error'
what(): det(): use of ATLAS or LAPACK needs to be enabled
Abandon (core dumped)
To avoid this problem, follow the advise of the faq of Armadillo : uncomment #define ARMA_USE_LAPACK in file /home/alpha/soft/armadillo-4.100.1/include/config.hpp and rebuild your project.
You can also create GNU Autotools projects and add following line:
bin_PROGRAMS=armadillo_example
armadillo_example_SOURCES=armadillo_example.cpp
armadillo_example_LDADD=-larmadillo
To Makefile.am file where your source code exist.
If you don't require optimized BLAS libraries, you can use the BLAS and LAPACK libraries that come with Armadillo.
Project properties > C/C++ Build > Settings > GCC C++ Compiler >
Includes > Include paths (-l): C:\armadillo-x.xxx.x\include
Then in Environment Variables > System variables, modify the Path
variable and add: C:\armadillo-x.xxx.x\examples\lib_win64\
Project properties > C/C++ General > Paths and Symbols > Libraries:
blas_win64_MT and lapack_win64_MT (it is important to add them
this way, with no path or .lib/.dll)
Then in Environment Variables > System variables, modify the Path
variable and add: C:\armadillo-x.xxx.x\examples\lib_win64\
And your Armadillo library in Eclipse is good to go.
I've used Eclipse 4.14.0 and Armadillo 9.850.1.

STM32 Eclipse + ARM GNU toolchain error linker

I use Eclipse + ARM plugin to build my projects. When I needed to use in my project the StemWin library, I configured my IDE to use external library.
I set
Preferences -> C/C++ General -> Paths and Symbols
I added in "Library Paths" the link to my folder includes library.
I also added the name of my library in tab "Library".
I checked the settings in the compiler tab and I ascertained all should be good.
When I tried to build my project I got an error from linker:
cannot find -lMyLib.a Hello C/C++ Problem
I double checked the name of my library and link, all are correct. This is the output of my linker:
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -L"C:\lib"
-T"C:\arm_toolchain\stm32_workspace\Hello\LinkerScript.ld" -Wl,
-Map=output.map -Wl,--gc-sections -o "Hello.elf" #"objects.list" -lMyLib.a
What should I do from here?
I faced the same problem before.
-l:STemWin526_CM4_GCC.a
-L"C:\Edu_Workspace\STM32F4\stm32f4_bsp_template\Drivers\Middlewares\ST\STemWin\Lib"
Above are my working settings.
With -l:<archive file name> the colon : is important for archive file linking.
And -L will contain library path.
Also for stemwin make sure to compile with hardware floating point
-mfloat-abi=hard -mfpu=fpv4-sp-d16
the convention for the -l option of the linker (say you give -lMyLib.a as a linker option) is to search for a library file with "lib" prepended to the given name and .a (or .so) appended, i.e. your command line searches for a file libMyLib.a.{a,so} which is probably not how it's named.
Either you rename your library according to this convention or give it to the linker command line omitting -l (provided your IDE allows you to do so).
Looks like the problem is in -lMyLib.a which means you're trying to link a static library as a dynamic one.
To link a static lib you have to use its path as with ordinary .o files: ... /path/to/MyLib.a
and the resulting command line should look something like
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -L"C:\lib" -T"C:\arm_toolchain\stm32_workspace\Hello\LinkerScript.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "Hello.elf" #"objects.list" /path/to/MyLib.a
UPDATE:
Although it might fix the issue, turns out it's not true:
-llibrary
-l library
...
Normally the files found this way are library files—archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l surrounds library with ‘lib’ and ‘.a’ and searches several directories.
(https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html)

Issues with g++ and Eclipse on Linux - unresolved symbols

I am running Ubuntu 64bit version, and downloaded the latest 64bit Eclipse.
Installed g++ along with build-essential. Tested g++ to make sure it works from terminal, and it works fine.
alex#ubuntu:~/Desktop$ g++ test.cpp -o test
alex#ubuntu:~/Desktop$ ./test
Hello World!alex#ubuntu:~/Desktop$
However, trying to build simple C++ Hello Word project(one of the default projects that comes with Eclipse), I am getting error.
Description Resource Path Location Type
Program "g++" not found in PATH Preferences, C++/Build/Settings/Discovery, [CDT GCC Builtin Compiler Settings] options C/C++ Scanner Discovery Problem
I have added Environment variable named g++ with value /usr/bin/g++ and the above error went away, however, now I am getting unresolved errors, though project compiles and in the Console shows !!!Hello World!!!
Description Resource Path Location Type
Symbol 'endl' could not be resolved test_hello.cpp /test_hello/src line 13 Semantic Error
Symbol 'cout' could not be resolved test_hello.cpp /test_hello/src line 13 Semantic Error
Symbol 'std' could not be resolved test_hello.cpp /test_hello/src line 10 Semantic Error
Have I correctly entered Environmental variable ?? How can I get fix the "unresolved" error ?? Thanks !
When compiling there are two important things to consider:
1.) Is my path up-to-date with executables?
2.) Is my library path correct?
It appears you satisfy 1.) but not 2.)
The unresolved symbol error means that Eclipse cannot find your library via LD_LIBRARY_PATH or some other medium. It's attempting to locate the standard compiled C++ library.
How did you install g++?
Kindly do this and post the results:
Project > Properties > C/C++ Build > Environment
If everything there appears nominal, you can try
/sbin/ldconfig
which should hopefully re-parse your system library paths and might update your environment.

Configuring LAPACK in Eclipse-Photran for fortran compiler on Windows

Update
Thank you Vladimir for the usefull insights in libraries. I took another approach, developping first in ubuntu (which was a lot easier then messing around with Eclipse/Cygwin/... and now I'm trying to port to windows, which goes rather ok, however I have some questions about that too, posted here: Problems with porting a fortran program from ubuntu to windows
Question
I currently have the following setup and can't get the lapack library configured so that my fortran code can compile:
Windows 7
Cygwin installation (for GNU fortran), added to the windows PATH
lapack and liblapack-devel installed with cygwin
resulting in liblapack.a and libblas.a in the folder C:/cygwin/lib
In my program I call the lapack library using the following code
program myProgram
!use lapack (stays commented now)
...
In Eclipse I used the following setup (with the Photran package):
Fortran Project: executable GNU fortran on Windows (GCC toolchain)
GNU fortran compiler: gfortran ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}
GNU fortran linker: gfortran ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}
I compiled the libraries libblas.a and liblapack.a, to use as a static library, for windows and they are located in the C:/cygwin/lib folder. In the GNU fortran linker properties, the libraries were called lapackand blasin the folder C:/cygwin/lib. This results in a part -L"C:/cygwin/lib" -llapack -lblas in the {$COMMAND} section of the compiler and linker. (thanx to #vladimir-f for the help)
In the output there are no error messages left anymore. Only I got now the following error in Eclipse and no final .exe or bins:
Errors occured during the build.
Errors running builder 'CDT Builder' on project 'Hamfem'
Internal error building project Hamfem configuration
Release
java.lang.NullPointerException
Internal error building project Hamfem configuration
Release
java.lang.NullPointerException
However, the result of the build is still an executable, in this case called Hamfem.exe. Running this file results in the error message (instead of the routine): The program can't start because cyglapack-0.dll is missing from your computer. Try reinstalling the program to fix this problem.
That file is currently located in C:/cygwin/lib/lapack/ but I want that this file isn't needed to run the program, so I can run it on different computers. Can someone collaborate on this?
Second, when copy-pasting the .dll file in the folder where the .exe is located, it runs for a brief second, generating a stackdump file. I can't use the debugger in Eclipse-Photran due to the 'Building Workspace' error. Eclipse gives the message Binary not found when I want to run it in Eclipse as a local Fortran program. Any ideas how to resolve this problem?
The problem is here
L/lib/lapack –llapack
try to change it for
-L/lib/lapack –llapack
probably it is in you Makefile.
i.e.
gfortran -funderscoring -O3 -Wall -c -fmessage-length=0 -L/lib/lapack -llapack -o
And make sure lapack.mod is really in /lib/lapack which is probably C:\cygwin\lib\lapack on Cygwin.

Eclipse: Cross Compiling using shared library. Linker error "cannot find -lMyProject"

So I am compiling for MIPS architecture on a Linux 386 host in eclipse CDT. I have a project that is supposed to give me a library I can use on another project.
Compiling of that project works just fine. I end up with a libMyProject file.
So in my second project I reference the library file with the -L option for the path and the -l option for the library. All names are correct, however I end up with a Linker error (file not found).
Thats invoking the linker:
mips-openwrt-linux-g++ -L"/home/user/workspace/MyProject/DebugLibrary" -o "MySecondProject" ./HelloWorld.o -lMyProject
And thats the error I get in eclipse:
/home/user/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lMyProject
collect2: ld returned 1 exit status
Any suggestions?
Ok I found it.
Had to append the extension .a to the library in the command line pattern of the linker:
${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT}.a ${INPUTS}