Cygwin: Error while linking .lib files - c++

I'm new with Cygwin and currently I'm trying to build a little project which would encrypt some files.
The problem I'm having is that when I try to build the .cpp with the command:
gcc test.cpp -I /cygdrive/c/OpenSSL-Win32/include/ -L/cygdrive/c/OpenSSL-Win32/lib/MinGW -lcrypto -lssl
(OpenSSL is installed at cygdrive/c/OpenSSL-Win32) I get the error:
/usr/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld: cannot find -lcrypto
/usr/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld: cannot find -lssl
collect2: error: ld returned 1 exit status
I can't understand why It can't to find the libraries, because I clearly have libssl.lib and libcrypto.lib there. Sorry if my question sounds silly I'm with all this. Thanks.

Related

mingw cannot find my dependencies folder for GLFW

I'm trying to compile the code found in https://www.glfw.org/documentation. This code is in "main.cpp" and I have a folder in the same directory called "dependencies" containing: "glfw3.h", "glfw3.lib" and "libglfw3.a".
project directory
dependencies
I go to the directory in powershell and run:
g++ main.cpp -ldependencies .\dependencies\libglfw3.a -lopengl32 -lgdi32
and it returns:
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ldependencies: No such file or directory
collect2.exe: error: ld returned 1 exit status
What have I done wrong?
I've looked all the internet for solutions but none have worked even when I exactly do what is shown on the tutorial or solution, im quite stuck. I think its because im attempting to do this without an IDE (I used visual studio) and until recently i've only did C++ development with an IDE and i'm inexperienced with compiling and linking outside of IDE's.
g++ main.cpp -ldependencies .\dependencies\libglfw3.a -lopengl32 -lgdi32
should be
g++ main.cpp -Ldependencies -lglfw3 -lopengl32 -lgdi32
-L for a directory to search, -l for the name of the library to link with.

libgtest.so error adding symbols: DSO missing from command line

I have been using gtests for unit testing a personal project. Last week I upgraded to the LTS version of Linux Mint. Unfortunately, after that event, I haven't been able to compile my project due to gtests linking problems.
The following error is being issued:
/usr/bin/x86_64-linux-gnu-ld: build/tests/policies/roundrobin_tests.o: undefined reference to symbol '_ZN7testing4TestC2Ev'
/home/myuser/Documents/googletest-release-1.8.0/googletest/libgtest.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I have generated both libgtest.so and libgtest_main.so through CMake 3.10.2. The gtest version is the release-1.8.0, the same I used to have before.
Those libraries are located in /usr/lib and the corresponding include folder has also been copied to /usr/include. I made sure that this location is in my ld path and that is not the problem.
My compiler is g++ v7.3.0 and the command Im using to compile the testes is:
g++ -std=c++14 -Wall -O3 -Iinclude build/tests/policies/roundrobin_tests.o -lgtest_main -pthread -o bin/policies/roundrobin_tests
I have tried altering the order of the elements in the command, explicitly adding -L/usr/lib and -I/usr/include without luck. A funny fact is that if I take off the -pthread flag, the error is still the same.
The same command was used before and the only difference is the compiler version I am using now as I used g++ 5.4.0 before. Any insights on how to solve this?
edit: Just tested the same process with g++ 5.4.0 and CMake 3.5 and the same problems ocurred.

Boost and ssl client server building issue on Linux

I have installed boost as a third library when I install pcl (Point Cloud Library).
Now I am trying to run client and server programs http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/example/cpp03/ssl/client.cpp
When trying to link the required libraries:
g++ -I /usr/include/boost/ server.cpp -o server -lboost_system -lssl -lpthread
following error appears:
/usr/bin/ld: /tmp/ccRbD849.o: undefined reference to symbol
'ERR_reason_error_string##OPENSSL_1.0.0'
//lib/x86_64-linux-gnu/libcrypto.so.1.0.0: error adding symbols: DSO
missing from command line collect2: error: ld returned 1 exit status
When I searched the usr folder the Boost folder exists only inside include subfolder.
What can I do to solve this problem.
[...] libcrypto.so: [...] DSO missing from command line
spells it out! You are missing
-lcrypto
on the linker command line. In fact I always use -lssl -lcrypto in tandem

compiling boost.asio using g++ compiler

I'm new to g++ compiler and also trying to start coding with boost.asio libraries, but have some difficulties compiling the code using g++.
I have installed boost libraries usingsudo apt-get install libboost-all-dev and boost folder is located in /usr/include directory, and whole scenario:
geek#ubuntu:~/workspace/HelloBoost/src$ g++ -I /usr/include/ -l boost_asio HelloBoost.cpp
/usr/bin/ld: cannot find -lboost_asio
collect2: ld returned 1 exit status
Thanks for your answers.
Did you read about using boost.asio ? Apparently, it looks like a headers only library, and you only need to link -lboost_system -lboost_regex -lopenssl

/usr/bin/ld: cannot find -lboost_system

Getting error:
/usr/bin/ld: cannot find -lboost_system
collect2: ld returned 1 exit status
I already ran ldconfig and checked with ldconfig -v:
libboost_system.so.5 -> libboost_system.so.5
I used find to get the location of the library:
/usr/lib/libboost_system-mt.so.5
/usr/lib/libboost_system.so.5
Here is part of the command:
-Wl,-gc-sections -L/usr/lib -lboost_system -Wl,--end-group
Honestly do not know what is causing the problem. Tried everything. Any help is necessary
(Answered in a comment. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
The libs are actually in boost_1_55_0/stage/lib. So its -L/root/boost_1_55_0/stage/lib and I had to add that directory to /etc/ld.conf.d/libs.conf and ran ldconfig with it.
#Drax noted:
Only if you do not install boost. or Install it in a custom directory