Compiling omniORB with minGW error : undefined reference to `wWinMain', even if -municode used - c++

I'm newbee with minGW. I'm trying to compile omniORB 4.2.3 with minGW in order to link the libraries with my applications developed on Dev-CPP 5.11 . I use the same toolchain for both. The gcc version is 4.9.2 (tdm64-1).
I googled everywhere as possible and found the linker option -municode. But the error persists. I tried the wrapper solution too.
Here is the lines of the error :
+ gcc -oomnicpp.exe -mthreads -Wl,--enable-runtime-pseudo-reloc -municode -L../../../../../lib/x86_win32 cexp.o cccp.o config.o alloca.o index.o
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_w.o): In function `wmain':
C:/crossdev/src/mingw-w64-v3-git/mingw-w64-crt/crt/crt0_w.c:23: undefined reference to `wWinMain'
collect2.exe: error: ld returned 1 exit status
Thanks for help.

Related

Affdex SDK Compilation error with undefined reference to `Visualizer::Visualizer()'

I wish to setup Affectiva SDK 4.0.0 for Linux and hence, have started working on example apps from https://github.com/Affectiva/cpp-sdk-samples
I have Ubunutu 16.04, OpenCV 2.4.11, Boost 1.63, cmake 3.8.1, pre-installed gcc 5.5.0 and manually installed gcc 5.4.0 (because I could not find a proper setup for gcc 5.4.1 as required).
When I try to run below command to compile the code from video-demo folder:
g++ video_analyse.cpp -o video_analyse -std=c++11 -I$HOME/affdex-sdk/include -L$HOME/affdex-sdk/lib -I$HOME/sdk-samples/common -l affdex-native -l boost_program_options `pkg-config opencv --cflags --libs`
The error points to below line of code:
shared_ptr<PlottingImageListener> listenPtr(new PlottingImageListener(csvFileStream, draw_display));
And receive error:
/tmp/ccWtKCG0.o: In function `PlottingImageListener::PlottingImageListener(std::basic_ofstream<char, std::char_traits<char> >&, bool)':
video_analyse.cpp:(.text._ZN21PlottingImageListenerC2ERSt14basic_ofstreamIcSt11char_traitsIcEEb[_ZN21PlottingImageListenerC5ERSt14basic_ofstreamIcSt11char_traitsIcEEb]+0x148): undefined reference to `Visualizer::Visualizer()'
collect2: error: ld returned 1 exit status
The exact same error is received with gcc 5.5.0 as well.
If I comment everything starting from that line of code, then the compilation happens successfully.
Please guide me on this. Either on how to install the exact version of gcc 5.4.1 as expected by the SDK dependency OR anything which I might be missing.

C++ Boost: undefined reference to `boost::system::detail::system_category_ncx()`

I am trying to use Microsoft REST SDK to create a server listening to HTTP requests. My current computer is Ubuntu 18.04, the server code is pretty simple.
I have already installed the library by following the instructions on libboost official website and I have checked files in /usr/local/lib/, there are libboost_random.so.1.68.0 so I presume that I have libboost library.
However when I try to compile the code with the following command:
g++ server.cpp -o server -lpthread -lcpprest -lcrypto -lssl -lboost_system
It shows:
/tmp/ccKWADuo.o: In function `boost::system::system_category()':
server.cpp:(.text._ZN5boost6system15system_categoryEv[_ZN5boost6system15system_categoryEv]+0x7): undefined reference to `boost::system::detail::system_category_instance'
/tmp/ccKWADuo.o: In function `boost::system::generic_category()':
server.cpp:(.text._ZN5boost6system16generic_categoryEv[_ZN5boost6system16generic_categoryEv]+0x7): undefined reference to `boost::system::detail::generic_category_instance'
collect2: error: ld returned 1 exit status
Thanks for any advices.
Boost consists of several independent libraries. Your linker error suggests you are missing libboost_system.so. You just mentioned libboost_random.so to be in your /usr/local/lib but is there also the required libboost_system.so?
[Problem solved] Reinstalling library libboost 1.68.0 helps. Error occurs when building from source, fixing those building errors will solve the problem.

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.

linking error in boost asio

I am getting below linking error while compiling a simple piece of code using pthread.
The system i am working on is x86_64 (gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11) and am compiling as -
gcc -lpthread ~/temp/temp.cpp -lrt -L"/usr/lib/x86_64-redhat-linux5E/lib64/".
Its evident that the problem is with pthread library. So i have two questions.
Q1. is it fine to use x64 pthread libs with x86 code. (In this piece of code it doesnt matter but it does in my usage) (I guess its not but how might i differentiate between x64 and x86 libs?)
Q2. i see pthread and lrt both are present at /usr/lib but even if i give that path it says -lpthread not found.
What am i missing here? Thanks for your help.
Error :
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
/tmp/cc2GQOUf.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Code :
#include <stdio.h>
#include <pthread.h>
int main()
{
pthread_t f1_thread;
return 0;
}
In compilation phase,compiler can use gcc or g++,but g++ will call gcc command automatically.But in link phase,linker can use g++ or gcc -lstdc++.Because the gcc command cannot link with the libraries that be used by c++ program automatically, so usually use g++to complete the link.
So the command g++ -g -lpthread ~/temp/temp.cpp -o temp should be ok.

linking error with update gcc from 4.6 to 4.8 (Windows MinGW)

My c++ library compiles fine in MinGW gcc 4.6, and I need to compile it under gcc 4.8 and the following error occured:
d000014.o:(.idata$5+0x0): multiple definition of `_imp___get_output_format'
d:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a(lib32_libmsvcrt_a-output_format.o):output_format.c:(.data+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
I just can not figure out a way to fix this . Any one got a clue?