Author Topic: [FIXED] I'm failing at combining c++ with a nRGB library written in c :(  (Read 3460 times)

0 Members and 1 Guest are viewing this topic.

Offline CiriousJoker

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +1/-0
    • View Profile
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>
...
}
« Last Edit: January 28, 2015, 08:11:37 pm by Virusscript24 »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: I'm failing at combining c++ with a nRGB library written in c :(
« Reply #1 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.

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile

Offline CiriousJoker

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +1/-0
    • View Profile
Re: I'm failing at combining c++ with a nRGB library written in c :(
« Reply #3 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?