0

I'm trying to compile a C program using libxml2 in Eclipse. It seems like my code doesn't have problems, but there are errors when I build my project.

The error output is in this screenshot: https://drive.google.com/file/d/0BwV-0_2diIaaQlZHM2Fwa2R0LWc/edit

Before this error, I had an “Undefined reference to” error, but it was because I forgot to link the library libxml2. Now it's the problem in the screenshot. I don't what to do.

[EDITED] I solved my problem I just need to put -nostartfiles in the linker flags.

4

2 回答 2

0

I solved my problem I just need to write -nostartfiles in the Linker Flags box :D To find "Linker Flags" box go to Your Project > Properties > C/C++Build > Settings > GCC C Linker > Miscellaneous

That's it.

Thanks for help.

于 2013-11-14T14:56:59.547 回答
0

我不认为你的解决方案是可以接受的,我认为当你的项目在其他环境中执行时会导致同样的问题(另一个 eclipse 配置,从控制台运行它等)当你定义了相同的功能时会发生错误更多在您的项目中不止一次,我敢打赌,这是因为您已经定义了与库中已有的相同的功能。

例如,如果我有一个 lib1.h 和一个名为 hello() 的函数,然后在你的 main.c 中编写相同的函数(链接该库),就会出现问题。实际上,在您的图像中,我可以看到“__data_start 的多个定义”

所以我认为你只需要更改有问题的函数名称,它就会被修复。

此外,如果您在程序中多次包含同一个库,则会导致此问题,但可以使用预处理器解决(如果您对此感兴趣,请在 google 上搜索,因为它会离题并做出我的回答太长)

于 2015-10-28T11:22:39.087 回答