简体   繁体   中英

c/objective-c question

I am truing to use ac function in a .c file from within my objective-c class. I have imported the header for the c file. but I am still getting a problem and my program would not compile.

Undefined symbols:

"gluUnProject(float, float, float, float const*, float const*, int const*, float*, float*, float*)", referenced from: -[GLView checkCollission:object:] in GLView.o ld: symbol(s) not found collect2: ld returned 1 exit status

Any idea how I can resolve this issue ? Any help is certainly appreciated. Qutaibah

This error is posted by the linker and not the compiler. Often this is caused by the code being compiled as C and included from C++ or the other way around.

You can normally fix this by ensuring that the function definitions in the header file enforces any C++ compiler to use C syntax by adding the following to the header:

#ifdef __cplusplus
extern "C" {
#endif

... definitions goes here ...

#ifdef __cplusplus
}
#endif

This method also ensures that the .c file itself is treating the function definitions as C and not by accident get compiled as C++.

If you do not wish to alter the header, you can encapsulate the #include statement in the same way. This will however not ensure correct compilation of the .c file itself.

EDIT: Just a thought: I presume that you are actually compiling the .c file?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM