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

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?

Related

Clang compilation into sysroot with newer glibc

I'm trying to compile with a sysroot for Ubuntu 22.04 from a Ubuntu 20.04 image, and I'm having quite a bit of trouble, getting linker errors like these:
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_symbind_alt#GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_preinit#GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_fatal_printf#GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__nptl_change_stack_perm#GLIBC_PRIVATE'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The exact same invocation works fine from a Ubuntu 22.04, using the exact same compiler and exact same sysroot.
Here's my setup:
// test.cpp
int main(){}
Compile command:
clang++ --sysroot ../build_rootfs/x86_64_jammy test.cpp
Where ../build_rootfs/x86_64_jammy is a sysroot created with multistrap (I can share a minimized multistrap config if it's relevant, but considering the same sysroot works fine from Ubuntu 22.04, the sysroot seems to not be the issue.
Things I have tried:
Using lld--same result
Using clang 14, both from apt.llvm.org and from the binary tarball
Notably, GCC is able to compile it by passing -L/usr/lib/x86_64-linux-gnu/9 -L/usr/lib/x86_64-linux-gnu (yes, even when compiling with --sysroot), but this seems strange as this is linking to libraries on the host system. Adding these flags does let the compilation succeed, but compiling from clang on 22.04 works fine without loading any of the system libraries (allegedly).
I assume this is an issue with glibc verisons, but I can't see how the host glibc version would matter when compiling from a sysroot, and it doesn't seem like any of the linker inputs are actually from the host system, so what's going wrong?
This gist has the verbose logs from clang on focal, gcc on focal, and clang on jammy for reference.

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

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.

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.

Linker error while compiling code in Windows

I am trying to compile my C++ code in Windows cmd.
I have implemented UnitTest++ in the project. When I run:
g++ main.cpp -IC:\Test\TreeObjModel\include -IC:\Test\unittest-cpp-master\UnitTest++
it gives the following error:
undefined reference to `UnitTest::RunAllTests()' collect2.exe: error:
ld returned 1 exit status
Can anyone help me to resolve this? Is any more info needed?
You probably are missing to compile some other cpp file (UnitTest.cpp?); or maybe you must link to some UnitTest library, where the code for UnitTest::RunAllTests() resides.
The command line option for linking a library with GCC is -l library_name.

GCC - Linking bass.lib on Ubuntu

I wrote an application on Windows using CPP and BASS, and now I have to get it running on Linux (UBUNTU).
I am using gcc version 4.5.2.
I have bass.lib in my directory from which I try to compile prog.cpp using the following command arguments:
gcc prog.cpp -L. -lbass.lib
But I get the following error:
/usr/bin/ld: cannot find -lbass.lib
collect2: ld returned 1 exit status
I figure that this is a linking error, the compiler is not finding Bass.lib but I have specified as an argument on the command line.
Not sure what to do, any help would be really great.
bass.lib sounds like the windows library. You cannot use libraries generated on windows, (likely generated with the MSVC compiler), on linux.
The linux version of the library seems to be named libbass.so , in which case you'd use -lbass as the linker argument , and possibly other compiler/linker flags as well depending on where on the system you install the library. The bass.txt in the linux download of libbass have a few notes on what to do on Linux.