undefined reference to `u_fopen_48' - c++

I'm new to c/c++ and I guess I have some basic problem. I get undefined reference to u_fopen_48' error when compiling:
#include <unicode/ustdio.h>
int main(int argc, char** argv) {
UFILE* ufile = u_fopen("/home/emstol/Desktop/utf8demo.txt", "r", NULL, "utf8");
return 0;
}
Doc for this function is here. I'm using ICU 4.8.1 (compiled myself, step by step according to readme.html ;)), NetBeans with g++ underneath. If it helped this is what I see during building:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/emstol/NetBeansProjects/TextFairy1'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/textfairy1
make[2]: Entering directory `/home/emstol/NetBeansProjects/TextFairy1'
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/textfairy1 build/Debug/GNU-Linux-x86/main.o
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/emstol/NetBeansProjects/TextFairy1/main.cpp:4: undefined reference to `u_fopen_48'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/textfairy1] Error 1
make[2]: Leaving directory `/home/emstol/NetBeansProjects/TextFairy1'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/emstol/NetBeansProjects/TextFairy1'
make: *** [.build-impl] Error 2

You seem to have forgotten to link the library you used. You should refer to This page for instructions.
When building composite projects the compiler can't just easily find all it's required references. Most libraries come in the form of a shared object file (.so) and without their C code to be compiled along with the rest of your project, while only supplying the headers for their functions. This allows the compiler to create "sockets" in the code for the functions to be placed into, but without telling the linker where these functions should be taken from - the link process will simply fail.
You must, therefore, explicitly tell the linker where to search for the symbols it will seek, and this is usually done with the -l flag, though it would appear the ICU library has taken a somewhat different approach to it.

Related

C++ application failing to build with 'cannot find -lmysqlpp' but it appears to be there

I'm trying to build an application with Netbeans and getting the following error:
/usr/bin/ld: cannot find -lmysqlpp
I believe this exists as per the below screen shots;
and here in my includes from Netbeans;
The below is the full output from Netbeans;
cd '/media/psf/DL/DL_src/FEC_src/docugirl'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/media/psf/DL/DL_src/FEC_src/docugirl'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk /app/bin/docugirl
make[2]: Entering directory '/media/psf/DL/DL_src/FEC_src/docugirl'
mkdir -p /app/bin
g++ -o /app/bin/docugirl build/Debug/GNU-Linux/docugirl.o -lm -lpthread /pcli/library/libcore.a /pcli/library/libsdd.a -lmysqlpp
/usr/bin/ld: cannot find -lmysqlpp
collect2: error: ld returned 1 exit status
make[2]: *** [nbproject/Makefile-Debug.mk:67: /app/bin/docugirl] Error 1
make[2]: Leaving directory '/media/psf/DL/DL_src/FEC_src/docugirl'
make[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
make[1]: Leaving directory '/media/psf/DL/DL_src/FEC_src/docugirl'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
BUILD FAILED (exit value 2, total time: 472ms)
For completeness, the source exists on a remote Debian server (as has previous successfully created and built mysql type applications).
So, I'm a little confused, I thought and assumed that I had the necessary mysql stuff in order to build this, I am able to build other mysql applications with this setup. Is this mysqlpp different/additional to the /usr/include/mysql and /usr/include/mysql++?
The /usr/include/mysql links to /usr/include/mariadb
Any help would be greatly appreciated here, thanks in advance...
#HEKTO This was indeed the problem but it seemed that the current release of Debian (10.5) did not include the libmysql++-dev package, the reasons for which are as yet unknown to me and although I had copied the mysql++ header files across, the libmysqlpp.so was indeed not there. In this instance, I resorted to using a previous release, although I believe the next release will include this.
See here: https://packages.debian.org/stretch/libmysql++-dev

C++ boost error

I'm building a code based on this fast factorial library, and it depends on boost and mpir. I'm running Ubuntu 14.04 and using Netbeans 8.0.2. To simply test the #include statements of the library I made this silly code:
#include <iostream>
#include <mpir.h>
#include <primeswing.h>
#include <xmath.h>
/*
*
*/
int main() {
long x = 4;
std::cout << x;
return 0;
}
When I try to compile it however I get the following error
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/arengorn/NetBeansProjects/BA'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/ba
make[2]: Entering directory `/home/arengorn/NetBeansProjects/BA'
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/ba build/Debug/GNU-Linux-x86/main.o ->lm
build/Debug/GNU-Linux-x86/main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/ba] Error 1
make[2]: Leaving directory `/home/arengorn/NetBeansProjects/BA'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/arengorn/NetBeansProjects/BA'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 114ms)
Can anyone help me with why is the boost library (which is installed and present under /usr/include) is not working?
As commented by Wintermute
You need to link libboost_system.so. Put -lboost_system in your linker flags.
That solved the problem.

Error with GMP with C++ in Netbeans (Windows 64-Bit)

I'm doing a project for school in which I am doing all kinds of different calculations involving prime numbers. These numbers tend to go quite big, hence I went looking for an arbitrary precision library. I decided to go for GMP since I had used it earlier in Game Maker (a relatively unknown program) since someone had made a dll for it.
Now, I have followed the install manual and went ahead to compile GMP. I had great difficulty in doing this as I am totally unfamiliar with UNIX and cygwin. Now that I have tried to include gmpxx.h in Netbeans for a test program, things are going wrong. My code is as follows:
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <gmpxx.h>
#include <stdarg.h>
using namespace std;
int main()
{
mpz_t a;
mpz_init(a);
//cout << mpz_probab_prime_p(a,20);
mpz_clear(a);
}
For both mpz_init and mpz_clear I am getting the same error:
relocation truncated to fit: R_X86_64_PC32 against undefined symbol '__gmpz_[init/clear]'
I am just guessing, but the problem could be any of the following:
Wrongly compiled
Bad code
Improper includes/links
It could very well be the latter, although I have experimented with adding directories for the header files and such. How would I fix this error?
Thanks in advance!
Edit:
Since this is my first post, could you point out what I need to clarify in order to make this question answerable?
Edit2:
This is the compiling log in Netbeans:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/firsttestgmp.exe
make[2]: Entering directory '/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP'
mkdir -p dist/Debug/Cygwin_4.x-Windows
g++ -Lpath/to/gmp/lib -lgmpxx -lgmp -o dist/Debug/Cygwin_4.x-Windows/firsttestgmp build/Debug/Cygwin_4.x-Windows/main.o
build/Debug/Cygwin_4.x-Windows/main.o: In function `main':
/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP/main.cpp:22: undefined reference to `__gmpz_init'
/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP/main.cpp:22:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__gmpz_init'
/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP/main.cpp:24: undefined reference to `__gmpz_clear'
/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP/main.cpp:24:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__gmpz_clear'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin_4.x-Windows/firsttestgmp.exe' failed
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/firsttestgmp.exe] Error 1
make[2]: Leaving directory '/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
Edit3:
As #rubenvd pointed out, the real error is this:
build/Debug/Cygwin_4.x-Windows/main.o: In function `main':
/cygdrive/e/Documents/NetBeansProjects/FirstTestGMP/main.cpp:22: undefined reference to `__gmpz_init'
It's important that linked libraries come after the object files which contain references to them. So Your compile command will need to be:
g++ -o dist/Debug/Cygwin_4.x-Windows/firsttestgmp build/Debug/Cygwin_4.x-Windows/main.o -lgmpxx -lgmp
If you installed GMP in a nonstandard location (which doesn't seem to be the case), you'll need to add the path to the library directory using the -L option.
Thanks everyone! I fixed my problem by going to:
Properties > Build > Linker > Libraries > Add Library
Then adding gmp.a and gmpxx.a, which I found in the gmp directory that I compiled.

Using Netbeans with Cygwin and SDL, including SDL.h creates strange error

I've got Netbeans C/C++ set up, Cygwin installed, configured and running correctly. SDL was installed from the sources using the Cygwin terminal. I've confirmed that Cygwin, Netbeans and SDL are all running correctly, I can write and compile C++ projects just fine with Netbeans and Netbeans can see SDL without having to include any files or anything, it just works like the default libraries.
#include <cstdlib>
#include <sdl2/SDL.h>
using namespace std;
int main(int argc, char** argv) {
return 0;
}
That's the code I'm trying to compile, Netbeans doesn't highlight the include for sdl.h, but when I go to build I get this:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/Cally/Projects/Test'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/test.exe
make[2]: Entering directory '/home/Cally/Projects/Test'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f "build/Debug/Cygwin_4.x-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
mkdir -p dist/Debug/Cygwin_4.x-Windows
g++ -o dist/Debug/Cygwin_4.x-Windows/test build/Debug/Cygwin_4.x-Windows/main.o
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin_4.x-Windows/test.exe' failed
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/test.exe] Error 1
make[2]: Leaving directory '/home/Cally/Projects/Test'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/Cally/Projects/Test'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
The build is successful when I don't include SDL. Anybody know what I'm doing wrong?
The error message looks really evil - but it just tells you it can't find a WinMain.
This is a known issue with SDL. Please add those libraries to your linker (order is mandatory!):
mingw32
SDLmain
SDL
You can either add -lmingw32 -lSDLmain -lSDL to linker options or add them through the library menu of linker config.
It's possible you need SDL_mixer too - if so, just add it last.
Please see also: http://content.gpwiki.org/index.php/SDL%3aTutorials%3aSetup
As a "dirty workaround" you can do this: undefine main.
SDL redefines main() as a macro with some additional stuff. You can verify this by egl. Ctrl + click on main / go to declaration / definition or check if it's formatted as makro.
#include <cstdlib>
#include <sdl2/SDL.h>
using namespace std;
/*
* If 'main' is defined we clear that definition
* to get our default 'main' function back.
*/
#ifdef main
# undef main
#endif /* main */
int main(int argc, char** argv) {
return 0;
}
Please see source of SDL_main.h (line 103+).

OpenCV 2.3 doesn't compile, undefined reference error

I'm using OpenCV in Windows 7 64bits and Netbeans 7.0. I tried to compile the next code using MinGW and cygwin but both fails with undefined references.
When I use MAT or FLANN and others I can't compile, but I'm adding all libraries (I tried only adding Debug ones, Release ones, only needed ones... but fails).
The same code in ubuntu works, but I need to compile it in windows too. I'm using the 2.3 compiled version (using CMake) and the installable one.
#include "opencv2\opencv.hpp"
#include <iostream>
using namespace std;
int main(void)
{
cv::Mat::eye(1, 1, 0);
return 0;
}
"/usr/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/cygdrive/f/Proyectos/C++/OpenCV23Sandbox'
rm -f -r build/Release
rm -f dist/Release/Cygwin-Windows/opencv23sandbox.exe
make[1]: Leaving directory `/cygdrive/f/Proyectos/C++/OpenCV23Sandbox'
CLEAN SUCCESSFUL (total time: 1s)
"/usr/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/f/Proyectos/C++/OpenCV23Sandbox'
"/usr/bin/make" -f nbproject/Makefile-Release.mk dist/Release/Cygwin-Windows/opencv23sandbox.exe
make[2]: Entering directory `/cygdrive/f/Proyectos/C++/OpenCV23Sandbox'
mkdir -p build/Release/Cygwin-Windows
rm -f build/Release/Cygwin-Windows/main.o.d
g++.exe -c -O2 -I/cygdrive/C/OpenCV2.3/build/include -MMD -MP -MF build/Release/Cygwin-Windows/main.o.d -o build/Release/Cygwin-Windows/main.o main.cpp
mkdir -p dist/Release/Cygwin-Windows
g++.exe -o dist/Release/Cygwin-Windows/opencv23sandbox build/Release/Cygwin-Windows/main.o -L/cygdrive/C/OpenCV2.3/build/x86/vc10/lib -lopencv_calib3d230 -lopencv_calib3d230d -lopencv_contrib230 -lopencv_contrib230d -lopencv_core230 -lopencv_core230d -lopencv_features2d230 -lopencv_features2d230d -lopencv_flann230 -lopencv_flann230d -lopencv_gpu230 -lopencv_gpu230d -lopencv_haartraining_engine -lopencv_haartraining_engined -lopencv_highgui230 -lopencv_highgui230d -lopencv_imgproc230 -lopencv_imgproc230d -lopencv_legacy230 -lopencv_legacy230d -lopencv_ml230 -lopencv_ml230d -lopencv_objdetect230 -lopencv_objdetect230d -lopencv_video230 -lopencv_video230d
build/Release/Cygwin-Windows/main.o:main.cpp:(.text+0xac): undefined reference to `cv::Mat::eye(int, int, int)'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text+0x106): undefined reference to `cv::fastFree(void*)'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text+0x16f): undefined reference to `cv::fastFree(void*)'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text+0x1dd): undefined reference to `cv::fastFree(void*)'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text+0x1fa): undefined reference to `cv::Mat::deallocate()'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text+0x20a): undefined reference to `cv::Mat::deallocate()'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text+0x21a): undefined reference to `cv::Mat::deallocate()'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text$_ZN2cv3MatD1Ev[cv::Mat::~Mat()]+0x66): undefined reference to `cv::Mat::deallocate()'
build/Release/Cygwin-Windows/main.o:main.cpp:(.text$_ZN2cv3MatD1Ev[cv::Mat::~Mat()]+0x5e): undefined reference to `cv::fastFree(void*)'
collect2: ld returned 1make[2]: Leaving directory `/cygdrive/f/Proyectos/C++/OpenCV23Sandbox'
make[1]: Leaving directory `/cygdrive/f/Proyectos/C++/OpenCV23Sandbox'
exit status
make[2]: *** [dist/Release/Cygwin-Windows/opencv23sandbox.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
Trying with MinGW libs:
"/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/f/Proyectos/C++/OpenCV23Sandbox'
rm -f -r build/Release
rm -f dist/Release/MinGW-Windows/opencv23sandbox.exe
make[1]: Leaving directory `/f/Proyectos/C++/OpenCV23Sandbox'
CLEAN SUCCESSFUL (total time: 350ms)
"/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/f/Proyectos/C++/OpenCV23Sandbox'
"/bin/make" -f nbproject/Makefile-Release.mk dist/Release/MinGW-Windows/opencv23sandbox.exe
make[2]: Entering directory `/f/Proyectos/C++/OpenCV23Sandbox'
mkdir -p build/Release/MinGW-Windows
rm -f build/Release/MinGW-Windows/main.o.d
g++.exe -c -O2 -I/C/OpenCV2.3/build/include -MMD -MP -MF build/Release/MinGW-Windows/main.o.d -o build/Release/MinGW-Windows/main.o main.cpp
mkdir -p dist/Release/MinGW-Windows
g++.exe -o dist/Release/MinGW-Windows/opencv23sandbox build/Release/MinGW-Windows/main.o -L../OpenCV/OpenCV2.3/build/x86/mingw/lib ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_calib3d230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_contrib230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_core230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_features2d230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_flann230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_gpu230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_highgui230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_imgproc230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_legacy230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_ml230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_objdetect230.dll.a ../OpenCV/OpenCV2.3/build/x86/mingw/lib/libopencv_video230.dll.a
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x4f): undefined reference to `cv::Mat::eye(int, int, int)'
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0xac): undefined reference to `cv::fastFree(void*)'
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x11a): undefined reference to `cv::fastFree(void*)'
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x191): undefined reference to `cv::fastFree(void*)'
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x1a7): undefined reference to `cv::Mat::deallocate()'
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x1ba): undefined reference to `cv::Mat::deallocate()'
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x1ce): undefined reference to `cv::Mat::deallocate()'
build/Release/MinGW-Windows/main.o:main.cpp:(.text$_ZN2cv3MatD1Ev[cv::Mat::~Mat()]+0x74): undefined reference to `cv::Mat::deallocate()'
build/Release/MinGW-Windows/main.o:main.cpp:(.text$_ZN2cv3MatD1Ev[cv::Mat::~Mat()]+0x63): undefined reference to `cv::fastFree(void*)'
collect2: ld returned 1 exit status
make[2]: Leaving directory `/f/Proyectos/C++/OpenCV23Sandbox'
make[1]: Leaving directory `/f/Proyectos/C++/OpenCV23Sandbox'
make[2]: *** [dist/Release/MinGW-Windows/opencv23sandbox.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
or
g++.exe -o dist/Release/MinGW-Windows/opencv23sandbox build/Release/MinGW-Windows/main.o -L../OpenCV/OpenCV2.3/build/x86/mingw/lib -lopencv_calib3d230.dll -lopencv_contrib230.dll -lopencv_core230.dll -lopencv_features2d230.dll -lopencv_flann230.dll -lopencv_gpu230.dll -lopencv_highgui230.dll -lopencv_imgproc230.dll -lopencv_legacy230.dll -lopencv_ml230.dll -lopencv_objdetect230.dll -lopencv_video230.dll
same result.
Are you using the precompiled MinGW libraries? (it appears so). I tried for a couple of days to get my project to link successfully under Code::Blocks. I was seeing the same sort of errors you describe (bad references, etc).
I finally recompiled OpenCV using the steps shown here, and all became well.
I guess the Problem is that the library path points to the vc10 directory (-L/cygdrive/C/OpenCV2.3/build/x86/vc10/lib) instead of the mingw directory (-L/cygdrive/C/OpenCV2.3/build/x86/mingw/lib). The ld-linker can't find the methods because they are mangled for the vc++ "link.exe".
If you use 64 bit, then you have also link against 64-bit libs:
-L/cygdrive/C/OpenCV2.3/build/x64/mingw/lib.
I have exactly the same issue. I am trying to compile my program under a 64-bit Windows 7 machine with MinGW. Here is several possibilities that may result in the problem:
1) You need to make sure OpenCV2.3/build/x64/mingw/lib is link. Be careful, don't link the project to the libs for visual studio or libs for x86.
2) Make sure the proper dlls are copied to the project directory, or have been added to PATH. For example, if you use this lib libopencv_core243.dll.a, you should make sure libopencv_core243.dll can be loaded by the project. This is not the cause of the problem. But I think it is also important to know.
3) Make sure the MinGW can compile x64 programs. This is what I use: mingw-w64 (But since mingw-w64 project is moving to mingw-w64.org it's better to use the new website). Unfortunately, the one that download from MinGW32 won't work. And the link from the official site of MinGW will bring you to a second one (MinGW32).
4) By default, MinGw may compile your project to a 32 bit program. In order to make sure it compiles for 64 bit, add this compile flag -m64. Otherwise, if you only link the project with all the 64-bit libs, it will result in the problem as well.