undefined reference to `DES_set_odd_parity' - c++

gcc, Ubuntu.
Have done:
sudo apt-get install libssl-dev
Build with -lssl, but during linkage get error:
undefined reference to `DES_set_odd_parity'
?
EDITED:
g++ linear_des.cpp -lssl

DES_set_odd_parity is part of libcrypto so you should try linking that as well. Something on these lines:
g++ linear_des.cpp -lssl -lcrypto
Hope this helps!
PS: It might be a good idea to make use of pkg-config tool & compile something on these lines:
g++ linear_des.cpp $(pkg-config --cflags --libs openssl)

Related

MSYS2 and libcurl, which libs to link?

I am having some big headaches linking statically libcurl in MSYS2 mingw.
I installed libcurl and all the listed dependencies from here
https://packages.msys2.org/package/mingw-w64-x86_64-curl
Since I am using CodeBlocks as IDE I need to supply a whole list of libs in form of lib#?.a, please keep in mind that I know nothing of Linux world and gcc tools and command line, otherwise I wouldn't be using an IDE!
Also I am not skilled enough to compile lib packages. I just need to write some portable code to do a https post request in cpp, so I need libcurl.
Can you tell me a complete list of all the needed libs to link against ? I tried all my best but I keep getting an infinity of unresolved symbols
UPDATE
After having checked what the package config for libcurl says, I have installed all the missing libs and used the following command line:
g++.exe -o MyProg.exe obj\Release\main.o -static-libstdc++ -static-libgcc -static -m64 -lcurl -lnghttp2 -lidn2 -lssh2 -lpsl -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lgdi32 -lwldap32 -lzstd -lbrotlidec -lz -lws2_32 -s
Despite that I am still getting tons of undefined references:
d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib\libcurl.a(gsasl.o):(.text+0x14): undefined reference to `gsasl_init'
[plus many other 'gsasl...' referrences]
d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libbrotlidec.a(decode.c.o):(.text+0x2d28): undefined reference to `BrotliTransformDictionaryWord'
[plus many other 'brotli...' references]
pkg-config will tell you the necessary flags. Install it from the package mingw-w64-x86_64-pkg-config.
Run it as pkg-config --libs --static libcurl.
Copy the output into "linker flags -> other". For me the output is -L/mingw64/lib -lcurl -lnghttp2 -lidn2 -lssh2 -lpsl -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lgdi32 -lwldap32 -lzstd -lbrotlidec -lz -lws2_32. Don't forget to add the --static flag, if you're not already doing so.

How to develop libvirt C++ apps in Mac OS

I want to develop c++ apps that use libvirt api (libvirt/libvirt.h) in Mac OS. In Ubuntu once I installed libvirt-dev, it was compiling fine. but in mac I cannot find a way to install libvirt-dev. Can someone point me to the correct path. Thanks :D
If you install homebrew first, from the Homebrew website, then you will be able to simply install libvirt with:
brew install libvirt
If you want to compile against libvirt, I would further suggest you install pkgconfig with:
brew install pkgconfig
After that you can use pkgconfig to find the switches and flags you need for libvirt like this:
pkg-config --cflags --libs libvirt
which will give you something like:
-I/usr/local/Cellar/libvirt/3.4.0/include -L/usr/local/Cellar/libvirt/3.4.0/lib -lvirt
So, in conclusion, you will then be able to compile C code with:
gcc program.c $(pkg-config --cflags --libs libvirt) -o program
or
clang program.c $(pkg-config --cflags --libs libvirt) -o program
or C++ code with:
clang++ program.cpp $(pkg-config --cflags --libs libvirt) -o program

Compiling OpenGL program with GLFW3

I installed GLFW3 and am trying to compile my OpenGL program with the following:
g++ -std=c++11 main.cpp -lGL -lGLEW -lglfw3
But here's the library error I get:
/usr/bin/ld: cannot find -lglfw3
collect2: error: ld returned 1 exit status
I also tried with pkg-config:
g++ `pkg-config --cflags glfw3 glew` -o myprog main.cpp `pkg-config --static --libs glfw3 glew`
it compiles but when I run myprog it says it can't find libglfw.so.3
But it is located in /usr/local/lib
http://www.brandonfoltz.com/2012/12/compile-glfw-on-ubuntu-and-fix-libglfw-so-cannot-open-error/
Ubuntu installs libglfw.so.3 in /usr/local/lib so you have to add this line to /etc/ld.so.conf
I had the same problem.
In my case was usefull following steps:
Download glfw source code
unzip it
cd glfw_folder
cmake . (with dot)
make
sudo make install
To check, copy and paste following command in your console "whereis libglfw3".
you should have output like this one: "libglfw3: /usr/local/lib/libglfw3.a" (or another path after ":").
My config: VAIO Pro 13/Ubuntu 16.04 LTS/ Intel HD4000.
P.S.: Yes, I'd tryed "sudo apt-get install libglfw3" and all dependenses.

wxWidgets lots of undefined references

I downloaded the source to the latest wx and managed to compile it without any issues.
Configured with:
../configure --enable-optimise --enable-stl --enable-unicode --enable-threads --enable-static --disable-shared --prefix=/usr/local
When I try to compile this example with:
g++-4.8 `wx-config --libs` `wx-config --cxxflags` test.cpp
I get alot of undefined refferences ( full list here )
How can I make this work?
When using static libraries, as you do (because of --disable-shared in configure command line), the libraries must come after the object file that references them (this is a general rule with all Unix-ish linkers and definitely with GNU ld). So the correct command line would be
g++-4.8 `wx-config --cxxflags` test.cpp `wx-config --libs`
or, just to keep it short, and because it does not matter where do the compilation flags appear:
g++-4.8 test.cpp `wx-config --cxxflags --libs`
You need to specify the wx libraries so the linker can resolve the references.

OpenCV on ubuntu 11.10

I've just updated my system from ubuntu 11.04 to 11.10 and now I can't compile anymore any C program that contain references to OpenCV libraries
I've already tried to reinstall OpenCV (I use the 2.1 version) but I'm stuck with this error:
/tmp/ccArHTZL.o: In function `main':
z.c:(.text+0x59): undefined reference to `cvLoadImage'
z.c:(.text+0xa0): undefined reference to `cvNamedWindow'
z.c:(.text+0xb1): undefined reference to `cvShowImage'
z.c:(.text+0xbb): undefined reference to `cvWaitKey'
z.c:(.text+0xc5): undefined reference to `cvDestroyWindow'
z.c:(.text+0xd1): undefined reference to `cvReleaseImage'
collect2: ld returned 1 exit status
In order to install OpenCV I've always followed this procedure:
$ sudo apt-get install libcv2.1 libcv-dev libcvaux2.1 libcvaux-dev libhighgui2.1
libhighgui-dev opencv-doc python-opencv
$ export LD_LIBRARY_PATH=/home/opencv/lib
$ export PKG_CONFIG_PATH=/home/opencv/lib/pkgconfig
$ pkg-config --cflags opencv
-I/usr/include/opencv
$ pkg-config --libs opencv
-lcxcore -lcv -lhighgui -lcvaux -lml
$ g++ -I/usr/include/opencv -lcxcore -lhighgui -lm hello.c
Anyone can help me?
Why don't you use pkg-config to your favor?
g++ hello.c -o hello `pkg-config --cflags --libs opencv`
I think it is because of some changes from gcc 4.5 to gcc 4.6
Try this command instead (i.e., move the libraries to the end, instead of at the beginning of your command line) -- it works for me:
g++ -I/usr/include/opencv hello.c -lcxcore -lhighgui -lm
I'm still on kubuntu 10.10 so I'm not really familiar how does 11.10 work, but the most common answer to problems with not finding libraries is to use ldconfig with sudo. It'll refresh libraries database. If that doesn't help, look into /usr/lib, /usr/lib64 and /usr/lib32, because its the default place where apt-get throws libraries in. When you find the libraries, change the LD_LIBRARY_PATH so it contains the directory. I don't think that /home/opencv/lib is where they are, but i don't know Your environment
I just upgraded to 11.04 on my laptop and having similar issues. I would try building the latest version of OpenCV (2.3.1) and see if this fixes anything, this seemed to fix quite a few issues for me.
Use the following command, it worked for me:
gcc pkg-config --cflags opencv opencv.c -o open_cv pkg-config --libs opencv