I am facing a problem,
When I am using Makefile to install a software, I am getting this error
/usr/bin/ld: cannot find -lg2c
When I am searching libg2c
Its showing the path:
/home/guest/Downloads/mdsplus/math/libg2c.a
/home/initm03/Desktop/mdsplus/math/libg2c.a
/home/initm03/Downloads/mdsplus/math/libg2c.a
/usr/local/mdsplus/math/libg2c.a
Please so the needful if possible
The linker needs to know where to look for the library.
use the --library-path commandline switch or the LD_LIBRARY_PATH environment variable to specify the path of your libraries.
In the makefile, you'll need to tell the linker where to find libg2c;
Change
-lg2c
in the linker options in the makefile to;
-L/usr/local/mdsplus/math -lg2c
...and it should be able to find it and link correctly.
Related
I have ATLAS library "libatlas.so" in an unstandard directory "/opt/apps/gcc4_7/atlas/3.10.2/lib/"
I put the path along with other search paths in environment variable
LD_LIBRARY_PATH=/opt/apps/gcc4_7/atlas/3.10.2/lib:and_others
Then link my code with it as follow:
g++ mycode.o -L$LD_LIBRARY_PATH -latlas
It then say "ld: cannot find -latlas"
But if I add the path again as follow:
g++ mycode.o -L$LD_LIBRARY_PATH -L/opt/apps/gcc4_7/atlas/3.10.2/lib/ -latlas
I have no issues.
I cannot think of any reasons this could happen. Is it because the $LD_LIBRARY_PATH has too many paths in it?
I am converting a make file into cmake.
Make:
ORACLE = -L${ORACLE_HOME}/lib/ -lclntsh \
-I${ORACLE_HOME}/rdbms/public
CMAKE:
include_directories(${ORACLE_DIR}/include)
link_directories(${ORACLE_DIR}/lib)
project(DB_I)
add_executable(DB_I DB_I.c)
target_link_libraries(DB_I LINK_PUBLIC ${PROJECT_LINK_LIBS} -lclntsh)
install(TARGETS DB_I DESTINATION ${OPEN_FOX_BIN_DIR})
Error:
[ 53%] Linking C executable DB_I
/usr/bin/ld: cannot find -lclntsh
collect2: error: ld returned 1 exit status
I have ORACLE_HOME pointing to the directory where the files exist. The compiler is finding the OCI.H file it needs.
Directory structure...
ORACLE_HOME
include
oci.h
lib
libclntsh.so
I have even tried moving the libraries into the same directory as the source.
I even copied clntsh to /usr/bin.
What am I missing?
Thanks
You don't need the leading -l in the target_link_libraries
target_link_libraries(DB_I LINK_PUBLIC ${PROJECT_LINK_LIBS} clntsh)
Sorry
I just noticed the library file was a link. And the link was wrong.
I fixed that and all is good.
Thanks for your attention
The Problem is ORACLE_HOME is an environment variable.
In Make you get the value wich ${ORACLE_HOME} but in cmake you must write $ENV{ORACLE_HOME}
Also change your
link_directories(${ORACLE_DIR}/lib)
into
link_directories($ENV{ORACLE_DIR}/lib)
I am a novice to cmake and boost so this question might be missing something obvious:
I am building a project with cmake on linux (ubuntu) and I am trying to use boost logging in that project. Here is what I do to generate the Makefile:
rm CMakeCache.txt
cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-lboost_log -lboost_log_setup -lpthread -std=c++11" -DCMAKE_SHARED_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_MODULE_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_CXX_FLAGS="-DBOOST_LOG_DYN_LINK -std=c++11"
Compile goes through fine. (Some of these flags may be overkill -- I should only need the CMAKE_EXE_LINKER_FLAGS).
When I run the executable, I get the following unresolved reference:
-- ImportError: /home/mranga/gr-msod-sensor/gr-msod_sensor/build/lib/libgnuradio-msod_sensor.so: undefined symbol: _ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv
What flags am I missing? My boost library is set up and LD_LIBRARY_PATH points to the right location.
When I manually built a test program using the same linker flags, it compiles and runs fine so boost is installed correctly. I hope I have not missed the obvious.
(Moved question from the GNU Radio mailing list -- sorry if you are reading this post for a second time).
I believe the order of libraries in the linker command line in -DCMAKE_EXE_LINKER_FLAGS is incorrect. boost_log_setup depends on boost_log, so boost_log_setup should go first.
You seem to be linking against the non-multithreaded version:
-lboost_log
but the run-time linker seems to explicitely look for the multithreaded variant (the Boost doc site on that):
_ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv
^^
My guess hence is that you should try linking with
-lboost_log_mt
but the question whether that is right or not depends too much on your individual project to make it possible for me to clearly answer this.
I import j2objc to my project, but I still get error like Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_Test (public class Test in java source). I found something about wrong linking static library to project (libjre_emul.a). I found possible official solution add to Other Linker Flags flag "-l jre_emul".
Problem is I get error ld: library not found for -l jre_emul what does it mean? How can I fix this?
I tried extended command:
"-l jre_emul -ObjC -force_load ${PROJECT_DIR}/lib/libjre_emul.a"
Error library not found still remains. Any idea?
Thanks.
I think you have a spelling error in your other linker flags. Try to use something like:
-l"jre_emul"
The -force_load flag is no longer necessary. The issue is that the linker can't find the library because the path to it is not defined in your project (it's probably not in ${PROJECT_DIR}/lib, unless you explicitly put it there). The Update the Build Settings wiki section describes how to add the J2ObjC distribution path to your project's Library Search Paths build setting.
I am currently working on a simple data synchonizer in a mixture of Fortran and C/C++ by using OpenMPI libraries. The synchonizer compiles and links correctly, as far as I can see:
f95 -o fortran_mpi_test *.o -L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/
-L/usr/lib64/openmpi/1.4-gcc/lib/ -lmpi -lmpi_cxx -lstdc++
But when I execute the resulting executable on the same machined I get an error stating that one of the shared libraries is not found. That is confirmed by ldd.
Nevertheless the missing library libmpi_cxx.so.0 is located in one of the specified folders.
Could anyone give me a hint what I could have done wrong?
Check your environment variables. If your LIBRARY_PATH, LD_LIBRARY_PATH or similar vars have gotten out of sync or set to silly values you might not be searching the same directories for static libraries as you do for dynamics.
Also check out the ld.so manpage