Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: CiriousJoker on January 28, 2015, 03:04:10 pm

Title: [FIXED] I'm failing at combining c++ with a nRGB library written in c :(
Post by: CiriousJoker on January 28, 2015, 03:04:10 pm
So here's what i have:

I've started a plain c++ project and i wanna make a little game to practise.
Now my sample c++ class test works, and the library sample (nRGB) works too.
But i'm stuck at that point where i want to combine them. It always says something like:

Quote
undefined reference to `<every function i wanted to use out of the library>'

I tried this for days now, would be awesome if someone could tell a noob what to do  :3

Solution:

Code: [Select]
extern "C" {
#include <nGEO.h>
...
}
Title: Re: I'm failing at combining c++ with a nRGB library written in c :(
Post by: Vogtinator on January 28, 2015, 06:10:17 pm
(I couldn't take a look at your source - I'm on mobile, so this post may be useless)
Did you surround the nRGB header #include in an 'extern "C" {}' block?
It's needed because of C++ name mangling.
Title: Re: I'm failing at combining c++ with a nRGB library written in c :(
Post by: Legimet on January 28, 2015, 08:03:05 pm
Also see http://www.parashift.com/c++-faq/include-c-hdrs-nonsystem.html.
Title: Re: I'm failing at combining c++ with a nRGB library written in c :(
Post by: CiriousJoker on January 28, 2015, 08:08:44 pm
<3 you, thx :)

Didnt think of something like incompatibility.

Thought its all the same with less functions and that c++ compilers would notice if a file has .c attached to it ...

ps.: @Vogtinator isnt it also 2am for you here in germany?