![](/img/trans.png)
[英]c++ header file not found when compiling ios project in xcode
[英]Xcode iOS Project Fails When I Add C++ Code
我有一個OpenGL Xcode項目,但是當我想添加.h
和.cpp
文件時,即使我告訴不要編譯那些文件,它也不會編譯。
我收到此錯誤:
Apple Mach-O linker error
Undefined symbols for architecture i386:
"_read_png_image", referenced from:
read_png_texture(char const*, bool) in TextureUtilities.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
該錯誤的根本原因是read_png_image()
是C函數,但已使用C ++鏈接進行編譯-這會導致符號名稱混亂,其中包含有關函數參數類型的信息。
解決的方法是用extern "C"
包裝函數的聲明:
extern "C"
{
void read_png_image(char const*, bool);
}
大概您添加的.cpp
文件包含了聲明-可能形成一個預編譯的標頭。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.