/usr/bin/ld: cannot find -lgsl
/usr/bin/ld: cannot find -lgslcblas
collect2: ld returned 1 exit status
make[2]: *** [examples/slim_learn] Error 1
make[1]: *** [examples/CMakeFiles/slim_learn.dir/all] Error 2
make: *** [all] Error 2
I am getting a linker error while I use the make command and I think this is because the linker isn't able to find a particular GSL file even after I have set the path for LIBRARY_PATH env variable which apparently the C linker consults if unable to find a file. I am stumped as to how to fix this error. I have also set the C_INCLUDE_PATH to my gsl directory on an unrelated (most probably) note. Any help in resolving this error would be much appreciated as I am very new to linux and have no idea how to proceed.
Setting LIBRARY_PATH :
export LIBRARY_PATH=$LIBRARY_PATH:/home/PATH_TO_gls/gsl-1.16/
The make file is really long hence I am hesitant to post it here but this is the relevant part of the makefile: (please let me know if you would still like me to post the entire thing)
src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.requires:
.PHONY : src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.requires
src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides: src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.requires
$(MAKE) -f src/CMakeFiles/SLIM.dir/build.make src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides.build
.PHONY : src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides
src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides.build: src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o
src/CMakeFiles/SLIM.dir/slim_learn.c.o: src/CMakeFiles/SLIM.dir/flags.make
src/CMakeFiles/SLIM.dir/slim_learn.c.o: ../src/slim_learn.c
$(CMAKE_COMMAND) -E cmake_progress_report "/home/nmuralid/Desktop/Nikhil Documents/Yelp_Research/SLIM Recommender/slim-1.0/b$
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object src/CMakeFiles/SLIM.dir/slim_learn.c.o"
cd "/home/nmuralid/Desktop/Nikhil Documents/Yelp_Research/SLIM Recommender/slim-1.0/build/src" && /usr/bin/gcc $(C_DEFINES)$
Thanks in advance!
The solution was to set LIBRARY_PATH environment variable to the paths of the libgsl.so and libgslblas.so files. This was achieved as follows:
export LIBRARY_PATH=$LIBRARY_PATH:/home/path_to_gsl/gsl-1.16/cblas/./.libs/
export LIBRARY_PATH=$LIBRARY_PATH:export LIBRARY_PATH=$LIBRARY_PATH:/home/nmuralid/path_to_gsl/gsl-1.16/.libs/
We set the LIBRARY_PATH env in this case because the C-Linker looks inside these directories in-case it fails to find the files during linking.
gls-version 1.16 used.
Related
After I configured the cmake file for portmidi, and proceeded to use make to make the necessary files, I encountered this error during compilation:
- Build files have been written to: /home/mycomputername
/Desktop/portmedia/portmidi
[ 2%] Linking C shared library /Release/libpmjni.so
/usr/bin/x86_64-linux-gnu-ld: cannot open output file /Release/libpmjni.so: No such file or directory
collect2: error: ld returned 1 exit status
pm_common/CMakeFiles/pmjni.dir/build.make:251: recipe for target '/Release/libpmjni.so' failed
make[2]: *** [/Release/libpmjni.so] Error 1
CMakeFiles/Makefile2:87: recipe for target 'pm_common/CMakeFiles/pmjni.dir/all' failed
make[1]: *** [pm_common/CMakeFiles/pmjni.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
I'm quite confused. I've tried to insert the flags -fpic in the cxx-flags section of ccmake and change the default java install paths to no avail. Quite frankly, I think it has to do with the messing up of execution order, but I don't know where.
Any help will be greatly appreciated.
Apparently, there was some configuring to do in the directories that CMake points to in ccmake configuration. I just redownloaded the files and unzipped it into a newly made portmedia directory. Also, to make sure that you don't get any hiccups in making pm_defaults, refer to Nate's answer. To quote:
Apparently, one of the Makefiles generated by ccmake is broken. I was able to fix the issue by running
sed -i 's/pm_java\/pm_java/pm_java/' build.make
in the pm_java/CMakeFiles/pmdefaults_target.dir/ subdirectory of the
project after running ccmake . (on Ubuntu, though). (The sed
command replaces all occurrences of pm_java/pm_java by pm_java.)
Everything compiles, and I can even run pmdefaults from the
Release directory using
java -Djava.library.path=. -jar pmdefaults.jar
While OpenSSL ver. 0.9.8za was already installed on my system (darwin64-x86_64-cc), I elected to install the latest version, 1.0.1j, using the instructions for UNIX systems, in the "INSTALL" file within the downloaded tarball. I chose to configure with the 64-bit option, './Configure darwin64-x86_64-cc', and then ran the makefile. So far, so good. After about a minute, as I was thinking the installation would be successful, the compiler displayed following error messages, after compilation terminated:
Compile command line: './Configure darwin64-x86_64-cc' (Openssl suggestion for 64-bit)
duplicate symbol _OPENSSL_cleanse in:
../libcrypto.a(mem_clr.o)
../libcrypto.a(x86_64cpuid.o)
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [link_app.] Error 1
make[1]: *** [openssl] Error 2
make: *** [build_apps] Error 1
The problem appears to originate in the linker, but then again, I'm still a command line novice.
So, given this error, what needs to be changed in order to fully compile OpenSSL 1.0.1j?
When the automatic configuration route was taken (./config), the following error is given:
cc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include -DOPENSSL_THREADS -D_REENTRANT
DDSO_DLFCN -DHAVE_DLFCN_H -arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN
DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m
DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM
DGHASH_ASM -c -o obj_xref.o obj_xref.c
ar r ../../libcrypto.a o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
ar: ../../libcrypto.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: ../../libcrypto.a: Inappropriate file type or format
make[2]: *** [lib] Error 1
make[1]: *** [subdirs] Error 1
make: *** [build_crypto] Error 1
Update: The "PROBLEMS" documentation suggests changing two lines in the apps/Makefile and test/Makefile:
"LIBCRYPTO= -L.. -lcrypto"
"LIBSSL=-L -lssl"
to:
"LIBCRYPTO=../libcrypto.a"
"LIBSSL=../libssl.a"
Re-attempting make afterward, the same message was given.
My sincere thanks for the help and comments by jww, Jonathan L. and others gave/made. Should errors persist, I'll continue the search for the missing information and eventually post a solution.
I'm not sure what your problem is. Using XCode 6 (6.1.1, I believe) on Yosemite 10.10.1, I was able to get openssl-1.0.1j from OpenSSL.org and extract it. I then configured it with:
./Configure --prefix=/usr/openssl/openssl-1.0.1j darwin64-x86_64-cc zlib threads shared
With those, I was able to build, test and install without problem. That's pretty close to what you did; I simply have noted the presence of zlib (compression) and requested thread and shared library support — and specified a slightly out-of-the-way location to install it. (The top-level directory specified with --prefix existed but was empty.) I tried adding sctp to the configuration options, but no dice — an SCTP header is missing, so I didn't bother to try further.
I'm trying to compile a boost tutorial example from http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/tutorial/tuttimer1.html.
My CMakeLists.txt looks like the following:
project(boost)
add_executable(timer1 timer1.cpp)
set_target_properties(timer1 PROPERTIES LINK_FLAGS -lboost_system,-lpthread)
trying to build the whole thing with cmake, I get:
/var/www/C++/boost/build$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /var/www/C++/boost/build
Scanning dependencies of target timer1
[100%] Building CXX object CMakeFiles/timer1.dir/timer1.cpp.o
Linking CXX executable timer1
/usr/bin/ld: cannot find -lboost_system,-lpthread
collect2: ld returned 1 exit status
make[2]: *** [timer1] Błąd 1
make[1]: *** [CMakeFiles/timer1.dir/all] Błąd 2
make: *** [all] Błąd 2
But when I run:
g++ timer1.cpp -lboost_system -lpthread -o timer1
manually, everything works fine. Can someone please point me on what do I do wrong?
PS
When I try to use solution described in Turning on linker flags with CMake, I add to cmake the following lines:
set(CMAKE_SHARED_LINKER_FLAGS "-lboost_system,-lpthread")
set(CMAKE_MODULE_LINKER_FLAGS "-lboost_system,-lpthread")
set(CMAKE_EXE_LINKER_FLAGS "-lboost_system,-lpthread")
and I get the same error as above.
I strongly suggest that you use the CMake integrated FindPackage. CMake will find boost and pthreads for you.
Your CMakeLists.txt should look like this:
find_package( Boost COMPONENTS thread system filesystem REQUIRED ) #whatever libs you need
include_directories( ${Boost_INCLUDE_DIRS} )
find_package( Threads )
In the subfolder src:
set( LIBS_TO_LINK
${Boost_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
target_link_libraries( myApp
${LIBS_TO_LINK}
)
/usr/bin/ld: cannot find -lboost_system,-lpthread
Here the linker is looking for a library libboost_system,-lpthread.so. It is exceedingly unlikely that such a library exists on any UNIX system.
You probably want:
set(CMAKE_EXE_LINKER_FLAGS "-lboost_system -lpthread")
I am trying to cross compile samba server.
./config works just fine, but when I want to build with make the prompt says:
Linking shared library bin/libsmbclient.so.0
/opt/qnx630/host/linux/x86/usr/bin/ntoarm-ld: cannot find -lpthread
collect2: ld returned 1 exit status
make: *** [bin/libsmbclient.so.0] Error 1
Anyone knows a solution?
had this same problem w/mingw. got libpthreadGC2.a from ftp://sourceware.org/pub/pthreads-win32/dll-latest/lib/x86/, put it in C;\mingw\lib and renamed it to libpthread.a. i didn't know gcc's -l switch means "apprend 'lib' to the front and '.a' to the back" e.g. -lpthread = libpthread.a
Make sure that the pthread library is in the library search path of the linker.
I am new to Ubuntu and I had the following questions.
When compiling a C or any other program one often writes a command such as gcc hello.c -lm
I am told the -lm option is for explicitly linking the math library during the compiling
phase. I wanted to know where the library 'foo' is supposed to be located if linked with - lfoo.
This is an error I get when I was trying to install a package named SUPERLU which in turn depends on the existence of a package named PARMETIS. (ending of the stuff after running make)
/usr/bin/ld: cannot find -lparmetis
collect2: ld returned 1 exit status
make[1]: * [pddrive] Error 1
make[1]: Leaving directory `/home/gaurish108/Desktop/ResearchMeetings/SUPERPETS/SuperLU_DIST_2.4/EXAMPLE'
make: * [example] Error 2
What should I do ???? I found that there is no ld folder in my /usr/bin/......Should I modify my make.inc file in some way?
Take a look here: http://www.network-theory.co.uk/docs/gccintro/gccintro_21.html. -lm says "search for libm.a in the search path". libm.a is found in /usr/lib/libm.a.