Linux 板


LINE

先提供linux版本为:Linux Mint 17 Qiana 小弟目前在做专题中需要用到字串转成点阵图印出,故参考以下网页 https://github.com/descent/progs/tree/master/cpp11_utf8 为了能编译,照着以下网页步骤安装了clang与libc++ http://www.cnblogs.com/codemood/p/3142848.html 有先编译hello world,顺利的成功了也能执行 clang++ -g -stdlib=libc++ -std=c++11 -I/usr/include/c++/v1/ -I/usr/include/c++/v1/include/ `freetype-config --cflags` -Wall -W -I. -c hello.cpp clang++ -o hello hello.o -stdlib=libc++ -std=c++11 -I/usr/include/c++/v1/ -I/usr/include/c++/v1/include/ `freetype-config --libs` 在把字串转点阵图的main.cpp转.o档时跳出两个警告,说有两个变数没在程式码里调用到 (我认为是没有影响) main1.cpp:76:6: warning: unused variable 'starty' [-Wunused-variable] int starty = pen_y; ^ main1.cpp:75:6: warning: unused variable 'startx' [-Wunused-variable] int startx = pen_x; //startx与 starty需定义 ... ^ 2 warnings generated. 在把.o档转成执行档时跳出错误: xxs4129-Aspire-5750G xxs4129 # clang++ -o main1 main1.o -stdlib=libc++ -std=c++11 -I/usr/include/c++/v1/ -I/usr/include/c++/v1/include/ `freetype-config --libs` /usr/bin/ld: main1.o: undefined reference to symbol '__cxa_free_exception@@CXXABI_1.3' //usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line clang: error: linker command failed with exit code 1 (use -v to see invocation) 有去google过但还是看不懂如何解决 这是我用的 main1.cpp 跟原本的一样只是自己为了读懂多了蛮多注解 https://mega.co.nz/#!x4lR3Y6K!L8_Z5PmLnd_yYhewgQy1FZPsaDmU0MwqfUbffJs1wxQ 还请各位大大有空能帮忙看一下 --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 124.6.19.51
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Linux/M.1427708166.A.FBA.html x049:转录至看板 C_and_CPP 03/30 20:01
1F:→ lantw44: 编 main1.o 的时候有加 -stdlib=libc++ 吗? 03/30 22:37
2F:→ kenduest: hello 程式码编译要两行似乎多此一举 03/30 22:58
3F:→ kenduest: clang++ -o main1 main.cppp ..... 不就可以了 ? 03/30 23:02
4F:→ kenduest: 若你没有其他特殊多个程式码要编译,不需要 -c 然後分开 03/30 23:03
5F:→ kenduest: http://i.imgur.com/nV5c9Ga.png 03/30 23:08
6F:→ kenduest: 另外你的问题我比较想知道的是,你编译一般的 c++ 程式 03/30 23:22
7F:→ kenduest: 能够正常工作吗? 03/30 23:23
8F:→ x049: 我是因为这个程式才去装linux ,还是新手看不太懂指令编译 03/30 23:51
9F:→ x049: k大说的编译一般c++程式是说用上面clang++指令编译吗? 03/30 23:53
10F:→ kenduest: 这样说好了,原本没有修改的版本,你可以正常编译吗 03/31 00:00
11F:→ kenduest: 是的,用 clang++ 编译一般的 c++ code 03/31 00:01
12F:→ x049: 我试过只要有用到 -stdlib=libc++ 就会跳出一样的错误 03/31 00:08
13F:→ x049: 用c++版本的hello world也会跳出错误 03/31 00:11
14F:→ lantw44: 有点好奇是为了什麽功能才装 libc++ 的吗? 03/31 00:14
15F:→ x049: 在 wstring2utf8.h 里有个<codecvt> 好像只有clang libc++有 03/31 00:18
16F:→ x049: k大的那张图我有照着编译,第一个原版的编译跳出了好几行 03/31 00:23
17F:→ x049: 未参考定义到,第二个编译结果错误码与图上的差不多 03/31 00:24
18F:→ x049: 第3个结果跟第一个一样跳出好几行未参考定义到 03/31 00:26
19F:→ lantw44: 用 clang++ -v 看看 #include 搜寻路径 03/31 00:27
20F:→ lantw44: 感觉可能他先搜到 libstdc++ 的了 03/31 00:27
22F:→ x049: X8xX6MLk9FfmpPSeQ 这是我clang++ -v的结果 03/31 00:36
23F:→ lantw44: clang++ -v 後面接本来拿来编译的参数 03/31 00:39
24F:→ lantw44: -I 那些也都要,真的有编译东西它才会显示搜寻路径 03/31 00:47
26F:→ x049: DgEMfM41obJ6bjl2A 结果很长 所以就上传txt档 03/31 00:51
27F:→ sunneo: 因为codecvt不在标准内,你该考虑boost的utf_to_utf 03/31 00:52
28F:→ x049: 如果使用boost的utf_to_utf是单纯更动wstring2utf8.h档吗? 03/31 00:58
29F:→ lantw44: 刚看到 gcc 5 已经有 codecvt 了,可以尝试看看 03/31 01:25
30F:→ lantw44: http://libcxx.llvm.org/ 有说在 Linux 可能要多加参数 03/31 01:31
31F:→ x049: 看不太懂要加哪些参数 03/31 01:44
32F:→ x049: 我打了 clang++ -o main1 main1.cpp -stdlib=libc++ hellowo 03/31 02:35
33F:→ x049: d.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgc 03/31 02:36
34F:→ x049: c 但出现找不到-lc++abi 上面那个helloworld.cpp多打的 03/31 02:38
35F:→ kenduest: 为何你要加上 -nodefaultlibs 这个参数 @@ 03/31 02:54
36F:→ x049: 我看不太懂,照网页上的参数打 03/31 02:56
37F:→ x049: 在Using libc++ in your programs的linux下有两种 03/31 02:59
38F:→ x049: 我是参考那个的 03/31 02:59
39F:→ kenduest: 没关系,一般不用,不过你後面有指定其他的 lib 就还好 03/31 03:08
40F:→ kenduest: 另外感觉你这程式好像搞很久了... 03/31 03:08
41F:→ kenduest: 我这边测试过都是在 mac os x 环境,clang 本身没问题 03/31 03:08
42F:→ kenduest: clang 是 xcode 提供的,都可以正确编译 03/31 03:08
43F:→ lantw44: 我在 FreeBSD 测试,clang 预设用 libc++ 也很正常 03/31 03:09
44F:→ kenduest: boost 有替代方案,程式码简单改一下就好 03/31 03:10
45F:→ kenduest: 只是重点你系统还需要有一份 boost 03/31 03:10
46F:→ x049: 主要都卡在linux跟clang++才编译不过去吧,main的程式码倒是 03/31 03:10
47F:→ x049: 读懂了 03/31 03:11
48F:推 kenduest: 这样吧.. 我刚刚帮你改一下改用 boost 03/31 03:20
49F:→ kenduest: http://x.co/8f16Z 这是那个 wstring2utf8.h 档案内容 03/31 03:21
50F:→ kenduest: 记得你应该会用 apt-get install 装上 boost 相关套件 03/31 03:21
51F:→ kenduest: 我这边是装上 libboost1.55-dev 就可以了 03/31 03:22
52F:→ x049: 感谢大大,小弟正在安装boost中,想问编译时需要怎麽下指令呢 03/31 03:23
53F:→ kenduest: 忘记说还要装 libboost 这个 lib, 上面那是标头档案 03/31 03:27
54F:→ kenduest: 最後 -l 不要忘记加上像是: -lboost_thread 03/31 03:31
55F:→ kenduest: 结论我这边 apt 装上 libboost1.55-dev libboost1.55 03/31 03:32
56F:→ kenduest: 都懒用 mac os x or freebsd 应该也是解法 XD 03/31 03:33
57F:→ x049: 终於成功了,感谢大大,小弟在这里linux跟clang卡好久了 03/31 05:13







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP