EDIT2:未定义符号“在toupper” GCC 4.7 OS-X小牛10.9 C11
所以这里是该方案的一个示例:
#include <stdio.h>
#include <ctype.h>
int main()
{
int i=0;
char str[]="Test String.\n";
char c;
while (str[i])
{
c=str[i];
putchar (toupper(c));
i++;
}
return 0;
}
1)铛:
clang++ -std=c++0x -stdlib=libc++ -lc++ main.cc -o main
编译得很好。
2)g++-mp-4.8 -std=c++11 main.cc -o main
给出:
Undefined symbols for architecture x86_64:
"toupper(int)", referenced from:
_main in ccWjHauc.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
3)g++-mp-4.8 main.cc -o main
编译!
任何想法设置有什么问题?
==========
别人的帮助可以了解在gcc/MacPorts的/ OS 10.9哪些改变呢?
我曾经有一些第三方库在OS 10.8的一种工作编译脚本。 最近我更新到新的osx(10.9)和gcc 4.7从macports停止链接。特别是我有:
Undefined symbols for architecture x86_64:
"isspace(int)", referenced from:
这个问题非常类似于istype
一提到here。 但是,似乎isspace
不在libgcC++。dylib中。
任何想法什么尝试?
EDIT1:
确实,4.8解决了这一问题与isspace
,但另一个浮出水面 - toupper
:
Undefined symbols for architecture x86_64:
"toupper(int)", referenced from: ...
这到底是怎么回事?!它与新的Xcode(5.0)有关吗?
你有没有包含头文件? –
asalic
是的,问题仍然存在。 – Denis
顺便说一句,根据我的理解,没有标题将导致编译错误,而不是链接错误 – Denis