Linker Error while using openssl - c

I have the openssl folder here:
C:\Dev-Cpp\include\openssl
In dev c++ I gave the following to the linker command line:
-lssl -lcrypto -l<C:\Dev-Cpp\include\openssl>
and the following to when it calls the compiler:
-L<C:\Dev-Cpp\include\openssl>
After compilation the dev c++ shows this error:
cannot find -l<C:\Dev-Cpp\include\openssl>
ld returned 1 exit status

remove the -l<C:\Dev-Cpp\include\openssl> from you link line command.
-lssl -lcrypto
you have already linked to the openssl library with -lssl -lcrypto
If you want to specify the path where the library are saved. you have to use only
-L<C:\Dev-Cpp\include\openssl>

Related

(Windows) GCC linker cannot find -lcheck and -lsubunit (But all headers are fine)

I am trying to compile C code that uses check.h with this command on Windows 11:
gcc new_test.c s21_decimal.a -lcheck -lm -lpthread -lsubunit -o new_test
But then i get this error:
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lcheck: No such file or directory
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lsubunit: No such file or directory
collect2: error: ld returned 1 exit status
So, GCC cannot find check and subunit, but it sure finds check.h header and all the other headers.
What is the most common way to fix this?
Can I download check and subunit (are those .lib?) manually and give these to GCC? If I can - how do I do this?
GCC version: gcc (GCC) 11.3.0

libraries not found error/ library path in makefile

I am compiling my code with
gcc -o ./sample/createUsageXMLd ./obj/createUsageXML.o -L../../../third_party/lib/openssl-fips/2.0/LSBGCC64 -L../../../third_party/lib/curl/7.45.0/LSBGCC64 -lssl -lcrypto
But I get error
/
usr/bin/ld: warning: libssl.so.1.0.0, needed by ../../../third_party/lib/curl/7.45.0/LSBGCC64/libcurl.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcrypto.so.1.0.0, needed by ../../../third_party/lib/curl/7.45.0/LSBGCC64/libcurl.so, not found (try using -rpath or -rpath-link)
../../../third_party/lib/curl/7.45.0/LSBGCC64/libcurl.so: undefined reference to `SSL_CTX_set_srp_username'
../../../third_party/lib/curl/7.45.0/LSBGCC64/libcurl.so: undefined reference to `SSL_CTX_set_srp_password'
collect2: error: ld returned 1 exit status
I have the following in my
libraries third party folder
$ cd third_party/lib/openssl-fips/2.0/LSBGCC64/
$ ls
libcrypto.a libcrypto.so libcrypto.so.1.0.0 libssl.a libssl.so libssl.so.1.0.0
You also need to provide the name of the library that you wish to link,
gcc file.c -o file -L/path/to/libs -llibname
In your case, try providing -lssl after including the path to your libraries (which you've done using -L). Note that the prefix "lib" and suffix ".so" are not required.
I tried installing curl with yum install. I checked the version of installed curl.It was 7.29.0. My compilation was successful. Later I degraded the version of curl from 7.45.0 to 7.29.0 in third_party folder. Now it compiles fine

Linking fftw-3.3.6-pl2 while compiling my file using gcc

I'm trying to run a simple code that includes the fftw library. I know the code is right as it is provided as a test code by the authors. This is what I typed during compilation:
gcc my file.c -L/home/ankit/Desktop/fftw-3.3.6-pl2/lib/
-I/home/ankit/Desktop/fftw-3.3.6-pl2/include/ -lfftw -lm
I get the errors:
myfile.c: (.Text+0x2c):. undefined reference to 'fftw_plan_dft_2d'
collect2: ld returned 1 exit status
It wasn't a linking problem, installation was faulty and I had to use 'sudo make install' to get the permission for the installation to be successful. I could link it with 'gcc test.c -lfftw3 -lm' after. Thanks for your suggestions!

a gcc strange ld error when compile some ffmpeg application, libvorbisenc package not found

I follow the ffmpeg tuorial, and install ffmpeg via ppa
But when I compiled the tuorial02.c, I got gcc error:
/usr/bin/ld: /opt/ffmpeg/lib//libavcodec.a(libvorbisenc.o): undefined reference to symbol 'vorbis_encode_setup_vbr'
//usr/lib/x86_64-linux-gnu/libvorbisenc.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
My compile command is:
gcc -I /opt/ffmpeg/include/ -L /opt/ffmpeg/lib/ -o tutorial02 tutorial02.c -lavformat -lavcodec -lswscale `sdl-config --cflags --libs` -lpthread -lz -lm -ldl
I have searched the reason for hours. I can't solve this. Can anyone help me?
Added I have add -lvorbisenc to the end. the error is lib not found. and libvorivisenc2 has been install. so this question is not a duplicate of Strange linking error: DSO missing from command line
And My OS is Linux mint 17.3
The error is telling you that the static library libavcodec.a references symbols from libvorbisenc but libvorbisenc isn't explicitly in your link command (though it did find a good candidate from another shared library in the link command). You'll need to add -lvorbisenc or $(pkg-config --libs vorbisenc) explicitly to your command line.
(Older versions of binutils would let you bring in shared libraries implicitly in this situation; however, newer versions of binutils are stricter.)

crypto library not found in MinGW

I have a C code that uses openssl and crypto to do AES encryption.
It compiles in linux without problem.
But in windows and with MinGW it gives:
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lcrypto
collect2.exe: error: ld returned 1 exit status
I'm compiling using this:
gcc code.c -lcrypto -Ic:\OpenSSL-Win32\include -Lc:\mingw\msys\1.0\local\lib
What is the problem?
This is somewhat odd:
gcc code.c -lcrypto -Ic:\OpenSSL-Win32\include -Lc:\mingw\msys\1.0\local\lib
Try:
gcc code.c -Ic:\OpenSSL-Win32\include -Lc:\mingw\msys\1.0\local\lib -lcrypto
OpenSSL installs itself into /usr/local/ssl by default, which means your library is usually /usr/local/ssl/lib. Did you change it? I'm not sure what that translates to under MinGW.
Perhaps you could provide a ls of c:\mingw\msys\1.0\local\lib. If the library is not there, try to find it with find c:\mingw\msys\1.0\local -iname libcrypto.a (or libcrypto.so).

Resources