MySQL Connector Linker Problem - c++

Hey, I'm trying to compile a program with the MySQL C++ Connector but somehow I can't get the linking right.
The errors I get are:
mysql/lib/libmysqlcppconn.so: undefined reference to `std::ios_base::ios_base()#GLIBCPP_3.2'.... etc
alt text http://img156.imageshack.us/img156/4022/linking.th.png
locations:
libmysqlcppconn.so: mysql/lib/
libmysqlclient.so: /usr/lib/
I tried to follow the tutorial on mysql and some other pages but the results where the same, maybe I missed something.

OK, it seems like the connector (binary) requires a certain libstdc++.so version (5) since I couldn't fix that I had to use the sources. Some errors I encountered while compiling them where that I had to include <stdio.h>. Now Everything is working!

Related

How can I compile a mex function in Windows with Eclipse (4.20.0 version) and Matlab (R2021a)

I'm trying to compile a c++ mex function that I created according to the specifications given by mathworks here (Create a C++ MEX Source File). However, after following the steps of the answer in this thread to link Eclipse 4.4.2 and Matlab R2015a in a linux enviroment (old but the only one I've found about it), I get the following error:
undefined reference to `get_function_ptr' mpi_pevd_mex_f line 79, external location: C:\Program Files\MATLAB\R2021a\extern\include\MatlabDataArray\detail\ExceptionHelpers.hpp C/C++ Problem
I don't know what else is missing. I've been trying to find a solution, but nothing useful so far.
Thank you for your help.
I have found the problem. Apparently, I needed to add additional libraries to those detailed in most of the posts related to MEX files, i.e. libmex/ libmat/libmx.
Making use of the verbose mode in Matlab (mex -v MexFunction.cpp), I realized that these libraries were missing: libmwlapack, m, libmwblas, libMatlabEngine, libMatlabDataArray. After adding them, the error disappeared.

GCC and Include File Troubles

I've been having some difficulty compiling a piece of C++ code for the physics engine Bullet Physics, and was hoping to get some advice.
This is my first time using gcc as a compiler, and including directories for compiling in general, so I'm going to give my whole process of problem-solving because I'm not sure where I went wrong or what the pertinent information is.
When I first tried to compile the code I got a fatal error about "No such error or directory", so I decided to add the directory with the -I option (1). It fixed the first error, but another popped up. Again, I was able to make the error go away with a -I option to the directory needed(2).
Then I got a whole long list of errors like the following:
main.cpp:(.text+0x33): undefined reference to 'RagdollDemo::initPhysics()'
main.cpp:(.text+0x84): undefined reference to 'glutmain(int, char**, int, int, char const*, DemoApplication*)'
/tmp/cc4MqhHm.o: In function '__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0xe7): undefined reference to `std::ios_base::Init::Init()'
I tried a few different things, but the solution ended up using my home bullet folder (or usr/local/include/bullet/) with the --sysroot option (3).
This created a lot of errors for the C++ header files, and then I linked to a few more directories with -I (4-5), but at after one of the added directories the same set of errors that I thought I solved with the --sysroot addition popped up again (6).
I can't tell what to do now. I would guess that declaring the bullet folder as my root makes it impossible for the compiler to find the required C++ files in my actual root directories, but I don't what to do about that... and when I tried including the C++ files I needed, the compiler seemingly forgot I told it to use bullet as my root.
Final compilation I tried before I gave up and realized asking for help might be better than spending 3 hours looking at documentation without any idea of what the exact problem is. Numbers correspond to the steps above.
gcc
(3)--sysroot=/home/josh/bullet-2.82-r2704/
(1)-isystem/home/josh/bullet-2.82-r2704/Demos/OpenGL/
(2)-isystem/home/josh/bullet-2.82-r2704/src/
(4)-I/usr/include/
(5)-I/usr/include/c++/4.8
(6)-I/usr/include/x86_64-linux-gnu/c++/4.8/
./main.cpp
I'm using Ubuntu 14.04 LTS and my OS and emacs 24.3.1 as my IDE.
Any help would be greatly appreciated.
Best,
Josh
What you are seeing is not include issue. Linker is failing to link with symbols. You need to link with proper library, for example lglut

trying to use the basic tutorial for ogre in code::blocks produces undefined references to '__unwind_resume' and '__gxx_personality_v0'

When following this tutorial I'm getting the following errors: undefined reference to '__unwind_resume' and undefined reference to '__gxx_personality_v0'
The file producing these undefined reference error's is libboost_system-mgw47-mt-1_51.a. I have already tried the following fixes to no avail:
Forcing Code::blocks to use g++ instead of gcc.
Result: No change
Adding-lstdc++ to the list of libraries the linker links to.
Result: 39 more errors in addition to the __unwind_resume and __gxx_personality_v0 undefined reference errors.
Installing the latest MingW and pointing my compiler to use it instead of its own version
Result: Compiler errors now exceeds max value :(
image2 http://s24.postimage.org/3u6tik4dh/moreerrors2.jpg
Any help troubleshooting these errors is appreciated, I really want to get this thing working.
I found part of the solution, I got the compiler to create an executable file, but it currently throws OGRE::filenotfoundexception and terminates. I did this by downloading boost_1_53_0 and building libboost_system-mgw47-mt-1-53.a and linking to that instead of the other one, then it gave me the error on startup "the procedure entry point __gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll." So to work around that I went to orwell's mingw folder and found that libstdc++-6.dll in that folder was around 800 KB in size and the one codeblocks was using was 5 mb, I switched them out to see if it worked and it got the executable running now but it throws said exception and terminates.
EDIT1: Strangely enough simply adding a blank file called resources.cfg (the file that caused the exception) causes the program to run but now an Ogre windows appears asking for a rendering system
EDIT2: After realizing I'm supposed to copy everything from ogre's bin/release directory to my executable files directory (and the media directory to 2 folders up from my executables directory) I did that and everything finally worked perfectly!

Compiler doesn't find reference to zip_get_num_entries on Windows

I want to use libzip in my program in C++ to extract files from a zip archive. So firstly, I get the number of files in it, get their names and read them. To get the number of files, I use 'zip_get_num_entries'. Its prototype is:
zip_uint64_t zip_get_num_entries(struct zip *, int)
And the way I use this function:
int nbrEntries(0);
zip *archive = zip_open("myZip.zip", 0, 0);
nbrEntries = zip_get_num_entries(archive, 0);
When I wrote this code, Code::Blocks suggested me zip_get_num_entries, so there's no problem of header. But when I compiled, the compiler (MinGW) told me that:
undefined reference to `_imp__zip_get_num_entries'
So I tried its deprecated equivalent, zip_get_num_files and it worked. I included to the project libzip.dll.a that I made with CMake. I had two files: libzip.dll and libzip.dll.a.
I'm sure it's a library problem (notice that I didn't have this problem on MacOS) but I don't know how to solve this. Thank you!
EDIT: I searched their website and read that the implementation of zip_get_num_files was new when they released the library available on the website. So I searched in their Mercurial repo and found versions that were released 2 days ago (a little bit newer than the release on the website, which has almost 1 year). I built it with CMake and it worked!
"Undefined reference" means that there is no definition/implementation (as opposed to declaration/prototype) of the function available. You forgot to link the library. Since you use MinGW with g++, it will take something like -lzip on the command line or as parts of LDFLAGS.
There is a chance that you misconfigured something, too - in which case the symbol name may be different depending on a define. But the most likely case is that you forgot to link the dependency.
I finally succeed to use zip_get_num_entries! I searched their website and read that the implementation of zip_get_num_files was new when they released the library available on the website. So I searched in their Mercurial repo and found versions that were released 2 days ago (a little bit newer than the release on the website, which has almost 1 year). I built it with CMake and it worked!

Weird linker error on Borland C++ Builder 6

I've been trying to compile a Borland C++ Builder 6 project, but linker dies with exact following error:
[Linker Fatal Error] Fatal: Unable to open file '.OBJ'
Strange thing about it is that it doesn't give any file name except the extension. It looks like an internal bug, though googling for it didn't give any results. Has anyone encountered this error?
== SOLVED ==
It was actually an invalid compiler directive in one of the sourcefiles which caused linker command line to be corrupted. Thanks for help.
Check for illegal whitespace characters in your Linker command line.
If you don't find any, post your linker command line here (Off the top of my head found in Project -> Options -> Linker -> Command Line).
I've never used Borland C++ Builder, but that might sound like a broken project or a corrupted object file - I guess you have not had any compilation error.
A few steps you may want to take:
- rebuild the project
- check the exact command-line used to invoke the linker, and look for strange things in the custom project settings (in such a thing exists).
If you indeed find some strange things in the command-line, hand-editing the project file (kids, don't do this at home) to remove the offending part may be the last resort before building up a new project.
Ive seen this before with visual studio, normally if i stop the compiler building while its in the linking process, not sure if borland generates obj files during its linking process? have a search in your project directory, and delete the obj files possibly in a folder called "intermediate" and try again
I suspect whitespace or other characters such as - or + on your command line.