OIS GCC Compiler error - c++

im trying to compile a simple Ogre3d application using OIS; i override the function like so:
virtual bool keyPressed(const OIS::KeyEvent& arg);
However, i get linker errors like this:
CMakeFiles/thorium.dir/Application/Application.cpp.o:(.rodata._ZTVN7Thorium11ApplicationE[_ZTVN7Thorium11ApplicationE]+0x48): undefined reference to `Thorium::Application::keyPressed(OIS::KeyEvent const&)'
Ive added the library to my cmake as well as tried using a shared library but it also did not work. Im using the ois package and therefore havent compiled myself.
target_link_libraries(... OgreMain OIS.a)

Undefined reference error often occures when the library code not loaded.
Put libNAME.a file in lib searching path and compile modules with key
-lNAME

Related

Library using libclang: linker reporting undefined reference to method

as a project of my own, I'm writing a refactoring library (so it can by used by other applications) using libclang for code analysis.
The problem is when i try to compile my program to a static library everything is okey, but when i try to link my library (using some clang code) with some demo application (just main function calling my code) the linker is reporting:
./librefactor.a(renamer.o):(.data.rel.ro+0x60): undefined reference to 'clang::ASTConsumer::HandleInterestingDecl(clang::DeclGroupRef)'
./librefactor.a(renamer.o):(.data.rel.ro+0x80): undefined reference to `clang::ASTConsumer::HandleTopLevelDeclInObjCContainer(clang::DeclGroupRef)'
./librefactor.a(renamer.o):(.data.rel.ro+0x88): undefined reference to `clang::ASTConsumer::HandleImplicitImportDecl(clang::ImportDecl*)'
collect2: error: ld returned 1 exit status
Here is a makefile I build my library with: library makefile
Here is a makefile I build an example with: library example
I commented out some parts of the code to make the error as short as possible but they are some similiar errors (undefined reference) from other part of clang i use in my project.
Problem is I don't understand why linker can't find definitions of these functions/methods. They are not pure virtual in base class so I don't need to defined them. As I see it the linker is trying to find the definition of these in my part of the code istead in clang binaries. Could somebody please explain me where I'm wrong here and explain/repair it?

How to Install/Use libcurl with C++ on Windows/Eclipse CDT

Can someone please explain how to use libcurl with C++ on Windows with Eclipse CDT/Code::Blocks or a similar IDE?
I'm very new to C++ but I know my way around Java very well.
I'm using MinGW but I keep getting this error:
C:\Core\src>g++ -I"C:\curl\include\curl" -L"C:\curl\lib64" -lcurldll core.cpp -o
core.exe
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xc81): undefined
reference to `_imp__curl_easy_init'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xca7): undefined
reference to `_imp__curl_easy_setopt'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xcc4): undefined
reference to `_imp__curl_easy_setopt'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xcd1): undefined
reference to `_imp__curl_easy_perform'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xce1): undefined
reference to `_imp__curl_easy_cleanup
What I've Tried:
If I give the wrong library path/name it will tell me that it can not find the library. So clearly it FOUND the libcurldll.a/libcurl.a files but it isn't linking with them properly.
I've tried putting the actual libcurl.dll file from the bin into every source folder possible in my project.
I've tried going to C/C++ General > Paths and Symbols then added "curl" and "curldll" to libraries and "C:\curl\lib64" to the library search path.
I've tried manually adding the -lcurl, -lcurldll, -DCURL_STATICLIB, -L"C:\curl\lib64" options to the MinGW Linker tool.
This has been stumping me for days. Please help.

How to link mysql in dev c++?

I just downloaded http://dev.mysql.com/downloads/mirror.php?id=414392 and set include/bin/lib folders to my compiler(tdm-gcc 4.8.1) in dev c++.
I can use functions from mysql.h (#include )
But i cant compile program.
bcoz:
undefined reference to `mysql_init'
undefined reference to `mysql_select_db'
what i have to do?
You've got the '-L' arguments including the lib directories, but you don't appear to have a '-l' argument linking the actual library. I think what you want to add is '-lmysqlclient' or something similar. Please see the following page for more information:
http://dev.mysql.com/doc/refman/5.0/en/c-api-building-clients.html

Blowfish and undefined reference to `BF_set_key'

I have installed Win64 OpenSSL v1.0.1b and Visual C++ 2008 Redistributables from this page http://slproweb.com/products/Win32OpenSSL.html and added compiler (C:\OpenSSL-Win64\include) and linker paths (C:\OpenSSL-Win64\bin, C:\OpenSSL-Win64\lib, C:\OpenSSL-Win64) to Code::Blocks, but I still cannot compile my program.
Source code:
#include <cstring>
#include <openssl/blowfish.h>
int main() {
const char * key = "aaabbbcccdddeeefffggghh";
BF_KEY bfKey;
BF_set_key(&bfKey, strlen(key), (const unsigned char *) key);
return 0;
}
Error:
obj\Release\main.o:main.cpp|| undefined reference to `BF_set_key'|
I tried to add -lssl, -lopenssl, -llibssl, -lcrypto, but it doesn't work. Then I can see another error:
ld.exe||cannot find -lssl|
I have no idea (and Google also) what to do. Any ideas what I do wrong?
I'm not sure if you configured it properly. It seems like you also have to add the libraries your project is using somewhere in Build Options, on top of setting the library directories. Does this help? http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/
Because you are using the GCC compiler (MinGW) with Code::Blocks you have to change the library sear directory (C:\OpenSSL-Win64\lib) to C:\OpenSSL-Win64\lib\MinGW and to link the library that have the Blowfish function you must use -leay32 (in your case probably is -leay64).
Inside the directory C:\OpenSSL-Win64\lib\MinGW there are 2 files with the .def extensin that have the list of functions exported by each library (libeay32.a/libeay64.a and ssleay32.a/ssleay64.a), by the way if you use the -l option the file must be called lib.a; the if you want to use any of the functions on the library ssleay32.a/ssleay64.a you must link the file directly (for example C:\OpenSSL-Win64\lib\MinGW\ssleay32.a) or append lib to the name of the file.

GMP Library, compile error in C++, MinGW, Code::Blocks

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.