Error with GiNaC library - c++

I'm making a C++ program available under Linux, Mac and Windows environments, respectively.
It uses GiNaC library.
It works fine under Linux and Mac environment.
However, I failed to build it under Windows environment.
I used precompiled GiNaC files including header, library and executable files downloaded from http://theor.jinr.ru/~varg/web/proj/ginac/woe32/ .
The following is the console message, and bold text represents the error message.
08:19:09 **** Incremental Build of configuration Debug for project
metapro **** Info: Configuration "Debug" uses tool-chain "MinGW GCC"
that is unsupported on this system, attempting to build anyway. Info:
Internal Builder is used for build g++
"-LC:\Users\yoons\Documents\ginac-1.4.4-cln-1.2.2-2587288a-gmp-4.2.4-i586-mingw32msvc\opt\ginac\lib\"
"-LC:\vcpkg\packages\gsl_x86-windows\lib"
"-LC:\Users\yoons\Documents\boost_1_70_0\stage\lib" -o
myproject.exe a.o b.o main.o c.o d.o e.o -lginac
-lm -lgsl -lgslcblas c.o: In function `Z7ordmetaSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPPdS9_iiiS5_':
C:\Users\yoons\eclipse-workspace\metapro\Debug/../c.cpp:53:
undefined reference to
`GiNaC::symbol::symbol(std::__cxx11::basic_string, std::allocator > const&, unsigned int)'
collect2.exe: error: ld returned 1 exit status
08:19:10 Build Failed. 1 errors, 0 warnings. (took 1s.221ms)
A strange thing is that the error occurred only 'symbol' type not others such as 'ex' or other functions provided by GiNaC package.
If anyone knows the answer, please let me know.
Sora

Related

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 with eclipse cannot find thread library

I have downloaded and build the boost libraries with
bootstrap mingw
and
b2 toolset=gcc
and the libraries are created in
C:\Boost\boost_1_57_0\stage\lib
In eclipse I have added this directory as a library path
and added the library libboost_thread-mgw49-mt-1_57 with and without the .a on the end.
the g++ line looks like
g++ "-LC:\\Boost\\boost_1_57_0\\stage\\lib" -o MyThread.exe main.o MyThread.o -llibboost_thread-mgw49-mt-1_57
and I get the error message
ld.exe: cannot find -llibboost_thread-mgw49-mt-1_57 collect2.exe: error: ld returned 1 exit status
If I add the .a it is appended to the error message as expected.
what am I doing wrong?
Specify the library without the lib prefix (which is the UNIX convention):
g++ "-LC:\Boost\boost_1_57_0\stage\lib" -pthread -o MyThread.exe main.o MyThread.o -libboost_thread-mgw49-mt-1_57
There's even a chance that (with the help of some standard convention symlinks) you could just say -lboost_thread.
PS Don't forget to use -pthread as well

Configuring Eclipse with MinGW

My computer runs under Windows 7 32-bit. I have:
Installed MinGW using the installer (mingw32-base, mingw32-gcc-g++ and msys-base) to C:\MinGW\bin;C:\MinGW\msys\1.0\bin
Edited the Path to MinGW and MSYSM by opening System Properties->Enviroment Variables->Path and adding: C:\MinGW\bin;C:\MinGW\msys\1.0\bin; to the list.
Installed eclipse for C/C++ Developers.
I've Tried:
setting the Configuration to "Build" in Eclipse under Project->Properties->C/C++ Build. (But when I compile a test application, it resets to Debug, also If I click 'apply' afterwards.)
compiling both a C and a C++ Project.
I get the Following error message in the eclipse console:
**** Rebuild of configuration Release for project Cpp test Project ****
**** Internal Builder is used for build ****
g++ -O3 -Wall -c -fmessage-length=0 -osrc\Cpp test Project.o ..\src\Cpp test Project.cpp
g++ -oCpptestProject.exe src\Cpp test Project.o
Warning: .drectve `-aligncomm:"___hexdig_D2A",5' unrecognized
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/crt2.o(.text+0x1f1)C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: Dwarf Error: found dwarf version '4', this reader only handles version 2 information.
:crt1.c: undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/libmingwex.a(glob.o)(.text+0x5e3)C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: Dwarf Error: found dwarf version '4', this reader only handles version 2 information.
:glob.c: undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/libmingwex.a(glob.o)(.text+0x690):glob.c: undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/libmingwex.a(glob.o)(.text+0x7e9):glob.c: undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/libmingwex.a(glob.o)(.text+0x82d):glob.c: undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/libmingwex.a(glob.o)(.text+0xc0d):glob.c: more undefined references to `__chkstk_ms' follow
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 3057 ms.
I've been skimming the internet for an hour or so, read the MinGW installationguide a million times and followed some University installation guide for installing C++ eclipse. ALL TO NO AVAIL! Thanks in advance for your answers.

gcc compiler cant find external library

I'm having a question about the Boost library. I compiled it and i can use the library in a project. Now i made a new project and wanted to include . I added the library in the linker and in the C++ compiler. I'm using Eclipse
This is my compiler output:
18:45:16 **** Incremental Build of configuration Debug for project Asterretje ****
Info: Internal Builder is used for build
g++ -o Asterretje.exe main.o Vertex.o RouteCalculator.o Reader.o Graph.o Edge.o -llibboost_regex-mgw48-mt-1_55
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -llibboost_regex-mgw48-mt-1_55
collect2.exe: error: ld returned 1 exit status
18:45:17 Build Finished (took 915ms)
Does anyone know how to solve this?
Add switch -L<dir>, where <dir> is directory of boost libraries. And you should cut first 'lib' part from library file name, for example for libmylib.so you should pass -lmylib
Thanks for all the help
I've found the problem. I forgot to insert the searchpath.

undefined reference to `WinMain#16

I'm trying to install openCV to Eclipse C++. I installed Opencv and aded the paths and lib files but I get
**** Rebuild of configuration Debug for project test ****
**** Internal Builder is used for build ****
g++ -IC:\opencv\build\include -O0 -g3 -Wall -c -fmessage-length=0 -osrc\main.o ..\src\main.cpp
g++ -LC:\opencv\build\x86\vc10\lib -LC:\opencv\build\x86\vc11\lib -otest.exe src\main.o -lopencv_core247 -lopencv_core247d -lopencv_highgui247 -lopencv_highgui247d -lopencv_imgproc247 -lopencv_imgproc247d
C:/MinGW/i686-pc-mingw32/lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x3c): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
Build error occurred, build is stopped
I know this question has been asked before but in every one of them the answer was "forgetting to include main() function". But I have a main() function and I still get this error.
Do you have any idea what should I do?
The linker probably is defaulted to use the "Windows" subsystem, which means that the main entry point is not the "main" symbol as you expect it to be, but rather "WinMain".
You can specify the subsystem of your application by passing the following argument at your g++ command line:
-Wl,-subsystem,console
(FYI, for the "Windows" subsystem, you'd use -Wl,-subsystem,windows)
You can also set this in the Eclipse project settings in the linker configuration somwhere I believe.
Basically "console", as the name suggests, creates a console-based application whose default entry-point is the main-function, the other will create a Windows GUI application whose default entry-point is the WinMain-function.
Please give it a try :)