Configuring Eclipse with MinGW - c++

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.

Related

Error with GiNaC library

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

undefined reference during AVR building, linker error

I'm trying to compile and link AVR based program in Atmel Studio (7). I have got the error message in linking phase.
I am doing this procedure first time with this software, because I got this software for maintenance. And I heard that this software have been succesfully built previously in "some environment". I installed the newest Atmel Studio, and picked project file, and selected correct processor. After the linking phase started, the error message appeared regarding undefined reference.
Building target: 16k.elf Invoking: AVR/GNU Linker : 5.4.0
"C:\Program Files
(x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"
-o 16k.elf DanskOFP.o adc_drv.o -Wl,-Map="16k.map" -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -mmcu=atmega164p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega164p"
C:\Projektit\V2.34\DanskOFP\Atmega164p\Makefile(118,1): error: recipe
for target '16k.elf' failed DanskOFP.o: In function `CPRX':
C:\Projektit\V2.34\DanskOFP\Atmega164p\Makefile(118,1): error: recipe
for target '16k.elf' failed DanskOFP.o: In function CPRX':
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to__eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to __eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to__eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to __eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to__eewr_byte_m164p'
I expect that the internal definition regarding "__eewr_byte_m164p" should be found from somewhere, but I have no glue, has something changed between AVR versions, or should the definition presented some new practise ?
I guess that's a function from avr-libc, namely the target-specific function called from eeprom_write_byte(). Make sure that avr-libc in in the build/link path.

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.

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 :)

OpenCV, eclipse compile problem

I have a compile problem I can't figure out for OpenCV2.1 in c++.
Here is a simple test code I am trying to compile:
#include <iostream>
#include "cv.h"
using namespace std;
int main() {
cout << "Hello World" << endl; // prints !!!Hello World!!!
cv::Mat mtx;
return 0;
}
I a compile error with an undefined reference as follows
**** Build of configuration Debug for project CJMVideo ****
**** Internal Builder is used for build ****
g++ -IC:\OpenCV2.1\include\opencv -IC:\Program Files\Point Grey Research\FlyCapture2\include -O0 -g3 -Wall -c -fmessage-length=0 -osrc\CJMVideo.o ..\src\CJMVideo.cpp
g++ -LC:\OpenCV2.1\lib -LC:\Program Files\Point Grey Research\FlyCapture2\lib64 -Xlinker --enable-auto-import -oCJMVideo.exe src\CJMVideo.o -lcxcore210 -lcv210 -lhighgui210 -lml210 -lFlyCapture2
src\CJMVideo.o:C:/OpenCV2.1/include/opencv/cxmat.hpp:378: undefined reference to `cv::fastFree(void*)'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 1438 ms.
The error is C:/OpenCV2.1/include/opencv/cxmat.hpp:378: undefined reference to `cv::fastFree(void*)'
I believe I have compiled all the libraries correctly from the above command...What is the problem?
Thanks
Even though the message suggests it has not found that symbol on the OpenCV libraries, I must point out that from the command line pasted above, it seems you are trying to link your application against 64-bit compiled libraries, as indicated by -LC:\Program Files\Point Grey Research\FlyCapture2\lib64. That means you must compile OpenCV to be 64-bit too, or compile both to be 32 bits.
You are probably missing one library. On Windows, my OpenCV projects usually adds cv210.lib cvaux210.lib cxcore210.lib cxts210.lib highgui210.lib, but I use Visual Studio 2005 most of the times.
I have had problems linking cv::fastfree when the OpenCV lib was built with the intel TBB parallel library, building without TBB worked