(I know it is similar to questions previously asked, but I tried for hours and failed to successfully use advice like the one written HERE and in related threads; I'm too inexperienced and a slow learner).
I'm Using:
Code::Blocks 13.12 IDE,
GNU GCC Compiler,
MinGW's folders for holding GLUT and
other libraries + files (like GLAux.h).
Windows 7 OS
Error message:
In function `Z7LoadBMPPc':
undefined reference to `auxDIBImageLoadA#4'
=== Build failed: 1 error(s), 5 warning(s) (0 minute(s), 3 second(s)) ===
(Testing one of the proposed solutions, when I additionelly add a Glaux library to the linker's libraries, dozens of other undefined reference errors pop up.)
The above function's declaration is in the <gl\GLAux.h> header file:
AUX_RGBImageRec * APIENTRY auxDIBImageLoadA(LPCSTR);
But naturally I can't go further, and look into the Glaux library itself.
I only know how to solve (some) undefined reference problems if they refer to the code I've written. Here it is not the case.
.
Which version of the undefined reference problem am I dealing with?
What to do?
Project → Build options → Linker Settings → Add → GLAUX → OK. Also you need to specify the full link to the picture. And pucture must be BMP 24 bit.
Related
I'm trying to take advantage of some of OpenSSL's EC cryptography and ECDSA functionality to make a rudimentary blockchain simulation, but I've run into a major roadblock. I'm using the Code::Blocks IDE, and I've installed OpenSSL using the 64-bit binary found here: https://slproweb.com/products/Win32OpenSSL.html.
In Linker Settings, I added OpenSSL-Win64\lib\openssl.lib
In Search Directories > Compiler, I added OpenSSL-Win64\include
In Search Directories > Linker, I added OpenSSL-Win64\lib
However, when I compile, I get the "undefined reference to (function name)" error for every OpenSSL function I try to use. However, the compiler seems to be successfully including the header files, since it recognizes the new data types like EC_KEY. I suspect a linking error, but I'm not sure what could be wrong, since I have the link paths and static library linked as above.
Here is my build log:
mingw32-g++.exe -LD:\OpenSSL-Win64\lib -LD:\OpenSSL-Win64\include -LD:\OpenSSL-Win64 -o bin\Debug\BlockchainSim.exe obj\Debug\main.o obj\Debug\src\Block.o obj\Debug\src\BlockchainNode.o obj\Debug\src\Transaction.o obj\Debug\src\Valuable.o D:\OpenSSL-Win64\lib\openssl.lib
obj\Debug\src\BlockchainNode.o: In function `ZN14BlockchainNodeC2Ei':
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:18: undefined reference to `EC_KEY_new_by_curve_name'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:21: undefined reference to `BN_new'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:22: undefined reference to `EC_KEY_set_private_key'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:25: undefined reference to `BN_CTX_new'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:26: undefined reference to `BN_CTX_start'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:28: undefined reference to `EC_KEY_get0_group'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:29: undefined reference to `EC_POINT_new'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:30: undefined reference to `EC_POINT_mul'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:31: undefined reference to `EC_KEY_set_public_key'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:34: undefined reference to `EC_POINT_free'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:35: undefined reference to `BN_CTX_end'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:36: undefined reference to `BN_CTX_free'
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:37: undefined reference to `BN_clear_free'
obj\Debug\src\BlockchainNode.o: In function `ZN14BlockchainNodeD2Ev':
F:/School/Barrett/BlockchainSim/src/BlockchainNode.cpp:42: undefined reference to `EC_KEY_free'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
15 error(s), 0 warning(s) (0 minute(s), 0 second(s))
I'm hoping I'm just missing something simple here since I'm new to linking static libraries. A lot of similar issues seem to be solved by adding options to compile commands, but since I'm using Code::Blocks and linking OpenSSL as a static library, I'm not sure if those apply here. Any help is greatly appreciated.
Figured it out. The issue was that I had no C:/MinGW folder (as Code::Blocks installed MinGW within its own directory). I'm guessing the binary I used tries to detect existing compilers and compiles the library differently depending on what it finds.
I fixed it by installing default MinGW (with MSYS, in case that matters) with the default path (C:/MinGW) and then reinstalling the 32-bit binary OpenSSL linked in the original question, also in the default path (C:/OpenSSL-Win32). This made it so that within the C:/OpenSSL-Win32/lib folder, there was a new MinGW folder which I then included in the linker search directories.
I have just started learning programming, and I am facing troubles adding libraries ( Other than STD libraries) in my programs.
I use codeblocks IDE and I wanted to add a library CImg from the internet.
After reading many threads I have done the following steps however I still get an error loading one of the examples provided CImg people
Downloaded Cimg folder which has a Cimg.h file along with other example files.
Unzip the folder to E drive.
open code blocks>compiler settings(gnu gcc compiler)>search libraries
under search libraries I have compiler tab and linker tab where I have added the path of the downloaded folder.
next when I open an example provided by the developer, build and run it.
The cimg.h file open up and I get the following error:
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h||In function 'int cimg_library::cimg::fseek(FILE*, INT_PTR, int)':|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h|5617|error: '_fseeki64' was not declared in this scope|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h||In function 'INT_PTR cimg_library::cimg::ftell(FILE*)':|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h|5626|error: '_ftelli64' was not declared in this scope|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 10 second(s)) ===|
Please help me out, Also kindly explain to me what I am doing as I have no idea.
EDIT: As pointed out to me in the comments I have changed my compiler to TDM-GCC MinGW 64 bit compiler.
But now I get a different type of error, is it because I havent installed the compiler properly because I can run hello world using this compiler.
the error that i get is :
||=== Build: Debug in hello (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function cimg_library::CImgDisplay::paint()':|
E:\programming\cpp programming\hello\..\CImg-2.0.0_pre012317\CImg.h|9696|undefined reference to__imp_SetDIBitsToDevice'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Finally I have found out what were my mistakes and how to correct them.
I was using a 32 bit compiler, So I switched to one for 64 bits.
After that I had not linked gdi32 library. So when I went to linker settings and added gdi32 to linked libraries evrything started to work.
Thank you for helping me out.
i'm getting a peculiar issue when trying to compile my program. I don't have a huge ammount of experience with C++. I'm trying to simple create a function that can FTP put a file upto my plain FTP server. I'm using codeblocks IDE, and the GNU GCC compiler, and in the end, i thought to try a full fledged example i found online to test if it was me writing some silly code. I have installed the windows SDK with all libs, so i can confirm the files are present, and if i build without any code, there is no linker errors.
I copied the OP's code, as it looked fine, and he complained of no such issues.
http://social.msdn.microsoft.com/Forums/en-US/76eb8b89-4b96-41ba-b869-e30711f29256/ftpputfile?forum=vcgeneral
However when i attempt to build my project, i get a plethora of errors:
||=== Build: Debug in uploader (compiler: GNU GCC Compiler) ===|
C:\C++\uploader\main.cpp||In function 'void FileSubmit()':|
C:\C++\uploader\main.cpp|10|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
C:\C++\uploader\main.cpp|11|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
C:\C++\uploader\main.cpp|12|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetOpenA#20'|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetConnectA#32'|
obj\Debug\main.o:main.cpp|| undefined reference to `FtpPutFileA#20'|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetCloseHandle#4'|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetCloseHandle#4'|
||=== Build failed: 5 error(s), 3 warning(s) (0 minute(s), 1 second(s)) ===|
Any idea what i'm doing wrong here? Do i need to be using certain compiler settings?
For anyone else experiencing this problem.
The solution to this, as implied by Igor in the commends on the op, was too manually add a link to the lib. In code blocks, this is accomplished by going to project --> Build Options, click the linker tab, and then manually browse to the file and include it. This has now made my project compile. Why code blocks requires this I don't know. But it does, so thanks Igor.
I have compile OpenCV 2.4.1 statically without error using MinGW and CMake. I checked With_QT
I just unchecked BUILD_SHARED_LIBS and proceed with mingw32-make and mingw32-make install.
It was built without error and eventually I have bunch of .a file in the lib folder of opencv.
But after setting LIBS and INCLUDEPATH parameters of .pro file and running a simple application in Qt I have got errors.
I also add the following line to .pro file:
CONFIG += -static -static-libgcc
I provided last line error:
F:\OpenCV2.4.1\opencv-static\install\lib\libopencv_highgui241.a(grfmt_jpeg2000.cpp.obj):grfmt_jpeg2000.cpp:(.text$_ZN2cv13Jpeg2KDecoder10readHeaderEv+0x4f):
undefined reference to `jas_image_decode' collect2: ld returned 1
exit status mingw32-make[1]: ***
[release\test.exe] Error 1
mingw32-make: *** [release] Error 2 The process "C:/ming44/bin/mingw32-make.exe" exited with code %2. Error while building project test (target: Desktop) When executing build step 'Make'
Update
I figured out that the error is just when I call highgui.hpp methods. like the following error when I use cv::imshow():
F:\OpenCV2.4.1\opencv-static2\install\lib\libopencv_highgui241.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL17icvCreateTrackbarPKcS0_PiiPFviEPFviPvES4_+0x5e1): undefined reference to `CreateToolbarEx#52' collect2: ld returned 1
exit status mingw32-make[1]: *** [release\test.exe] Error 1
mingw32-make: *** [release] Error 2
Can anybody help me solve this problem.
Thanks
There were many questions as we proceeded through the fix process, so I'll try to summarize the answers to all of them here.
Unresolved Symbols
undefined reference to `jas_image_decode'
The jas_image_decode symbol is defined in libjasper (which is a 3rd party dependency of OpenCV). To resolve it, link against libjasper.a.
undefined reference to `CreateToolbarEx#52'
The CreateToolbarEx symbol is part of Windows API, and is therefore defined in system libraries (which are always supplied with a toolchain, MinGW in your case). You can always find against which library you should link to resolve such symbols by looking in MSDN (scroll down and see Library and DLL cells). In this case, you can see Comctl32.lib, however MSDN of course posts names of libraries in the format that Microsoft Visual C toolchain defines them. Since you are using MinGW toolchain, you'd have to convert (mentally) this name into the Unix naming convention of libraries, and in this case that would be libcomctl32.a.
undefined reference to `AVIStreamRelease#4'
Similarly to the previous case we find it here, and infer that we have to link against libvfw32.a.
NOTE: The paths to such system libraries (containing Windows API) are always searched automatically by the toolchain. Therefore, you shouldn't supply -L option during compilation/linkage, but only the library itself, i.e. -lcomctl32.
undefined reference to `cv::dft'
Well, that's again some component from OpenCV (cv namespace obviously suggests that). A bit of searching reveals that it is defined in the Core component. Accordingly, to resolve that symbol, link against libopencv_core.a.
The Approach
How do I find out which library to link against to resolve the missing symbol?
There is no rule of thumb or any direct recipe here, but rather a number of tricks and educated guesses which primarily come from experience. Here are a few examples:
For instance, in case of CreateToolbarEx, it was quite easy for me
to guess that it belongs to Windows API as long as I recognize the
Windows API naming convention of the function name. Consequently,
what I do next is type CreateToolbarEx into Google, jump to the
corresponding page on MSDN, scroll down, see what the library name
is, convert (mentally) to the Unix naming convention of libraries (see above),
and voila!
The case of OpenCV is more tricky. OpenCV is a 3rd party library and
the question whether it'll be painful to find out the library where
certain symbol is defined solely depends on the quality of the
documentation provided. Although, I can see that the OpenCV
documentation is pretty good, it is still missing these important
hints for every symbol, and that's a pity. However, we (developers)
have to be able to cope with problems like that regardless of how
crappy the documentation of a 3rd party library is, and get the job done.
That's why it is always a good idea to use file content searching utility
such as grep (popular on Unix OS family, but available for Windows
too in MSYS distribution). This way, for example in case of
cv::dft, you could run grep -r "void.*dft(" . in the root of
OpenCV source tree, and track down where that symbol is defined in
no time. After that you'd have to infer to which component the file
containing cv::dft belongs, but that should be straightforward, just look
around and see in which directory the file resides.
Conclusion
I swear that I've never used OpenCV in my life, but as you can see I was still able to locate all these missing symbols for you. As a result, we can conclude that the proposed techniques of searching for unresolved symbols are sort of reliable.
Finally, nothing of this is specific to OpenCV or Qt. You're dealing with basic programmer craftsmanship skills here. If you want to be productive software developer capable of solving such day-to-day routines rapidly, then grep is just one of many essential utilities which should undoubtedly be the part of your tooling arsenal.
I have built GMP for MinGW. The IDE I'm using is Code::Blocks. I don't have any problems with C functions of GMP. But I'm having problem with C++. The program I tried to run is as simple as this,
#include<iostream>
#include<gmpxx.h>
using namespace std;
main()
{
mpz_class a;
a=12345;
cout<<"value"<<a<<"\n";
return 0;
}
And the Errors I get are
F:\Compilers\C_Libraries\GMP\lib\libgmpxx.a(osmpz.o):osmpz.cc|| undefined reference to `__gmpz_get_str'|
F:\Compilers\C_Libraries\GMP\lib\libgmpxx.a(osfuns.o):osfuns.cc:(.rdata+0x1c)||undefined reference to `__gmp_asprintf_memory'|
F:\Compilers\C_Libraries\GMP\lib\libgmpxx.a(osfuns.o):osfuns.cc:(.rdata+0x20)||undefined reference to `__gmp_asprintf_reps'|
F:\Compilers\C_Libraries\GMP\lib\libgmpxx.a(osdoprnti.o):osdoprnti.cc|| undefined reference to `__gmp_doprnt_integer'|
F:\Compilers\C_Libraries\GMP\lib\libgmpxx.a(osdoprnti.o):osdoprnti.cc|| undefined reference to `__gmp_asprintf_final'|
||=== Build finished: 5 errors, 0 warnings ===|
Now, some additional data:
I don't have any problem with C functions. And also, if I remove cout<< statement the file compiles and runs fine. The problem is probably with overloaded operators.
libgmpxx.a and libgmp.a are linked with compiler. It can be seen in the error messages too...
The problem is probably with the libgmpxx.a alone. So, I built the Library again, but the files are same.
I used this tutorial build GMP with MSYS for MinGW. http://www.cs.nyu.edu/exact/core/gmp/ and http://suchideas.com/journal/2007/07/installing-gmp-on-windows/
The version of GMP I'm using is 5.0.4.
So, what I want to know is, what could be the problem? And how could it be solved?
And, if unsolvable and if you have the working files for 5.0.4 version, please share it. :(
I suspect the command to build your program specifies the libgmp* libraries in the wrong order. Make sure the libgmp.a library is specified after the libgmpxx.a library:
-lgmpxx -lgmp
If they are specified in the other order, then when pulling in dependencies from libgmpxx.a library, the libgmp.a library won't be searched.
From the ld linker's docs on the -l option:
The linker will search an archive only once, at the location where it
is specified on the command line. If the archive defines a symbol
which was undefined in some object which appeared before the archive
on the command line, the linker will include the appropriate file(s)
from the archive. However, an undefined symbol in an object appearing
later on the command line will not cause the linker to search the
archive again.
See the -( option for a way to force the linker to search archives
multiple times.
You may list the same archive multiple times on the command line.