gcc undefined reference to

我只是一个虾纸丫 提交于 2019-11-29 10:01:29

Your link command is wrong. Libraries should be specified at the end of the command:

gcc ttssample.o -o ttsample -L. -lttsapi

You could add preprocessor ifdefines around the DllExport call like so:

#ifdef _WIN32
// we are on windows

#elif defined __linux__
//we are on linux

#elif defined __APPLE__&__MACH__
// we are on mac

#endif // os specific

I added for the three platforms I have been compiling cross platform for. Do note that the keywords I use to recognize platforms may change, but the _WIN32 one has been tested with windows 7 and 8. I found these a year ago on sourceforge I think. I couldn't find the page right now, but I'll get back to you if I find it.

As I cannot yet comment on Nikos C's answer I'll comment it here: Your link command is correct, I can of course not see you files, so I assume your paths are correct. What is important is that -l's need to be in correct order according to dependencies, but this is usually not a problem as far as I have experienced.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!