Robert Sköld
Robert Sköld

Reputation: 752

#include <lib.h> gives symbol not found, why?

I have this code:

#include <iostream>
#include <mp4.h>

int main (int argc, char * const argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";

    MP4Read("filename", MP4_DETAILS_ALL );

    return 0;
}

And i've added -I/opt/local/include and -L/opt/local/lib to the path (where the mp4 library resides after installing it through macports), but all i get is:

Undefined symbols: "_MP4Read", referenced from: _main in main.o ld: symbol(s) not found

Even though XCode finds it and autocompletes properly...

Upvotes: 0

Views: 1531

Answers (3)

anon
anon

Reputation:

The -L flags tell the compiler where to look, the -l flag tells it what to look for.

Upvotes: 1

dirkgently
dirkgently

Reputation: 111150

You have only specified the paths. You need to link in the mp4 library. Something like the following:

g++ -I /.../ -L /.../ -lmp4 -o out main.cpp

Upvotes: 3

Antti Huima
Antti Huima

Reputation: 25532

You need to link the library most likely, i.e. add -lmp4 or similar to your linking commands.

Upvotes: 8

Related Questions