使用gettext链接器错误进行国际化 [英] Internationalise using gettext linker error

查看:99
本文介绍了使用gettext链接器错误进行国际化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试使用gettext字符串提取程序开始国际化。



我已经创建了如下示例代码。但它未能建立。



Hi I am trying to start with internationalisation using gettext string extractor.

I have created sample code as follows. But it failed to build.

#include "SupportLanguage.hpp"
#include <iostream>
#include <locale.h>
#define _(STRING) gettext(STRING)

#include "libintl.h"
using namespace std;
class SupportLanguage {

public:    
    int x = 0;    
    void display();
};

void SupportLanguage :: display(){
    cout << " Hello World" << endl;    
    cout<< "Welcome" <<endl;    
    cout << gettext("How are you doing ?") <<endl;
}

int main(){
 
    SupportLanguage sl ;    
    sl.display();
    return 0;
}



错误消息:



Ld DerivedData / Internationalize / Build / Products / Debug / Internationalise.app/Contents/MacOS/Internationalise normal x86_64

cd / Users / UserName / WorkPlace / Internationalize

export MACOSX_DEPLOYMENT_TARGET = 10.11

/ Applications /Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11。 sdk -L / Users / UserName / WorkPlace / Internationalize / DerivedData / Internationalize / Build / Products / Debug -F / Users / UserName / WorkPlace / Internationalize / DerivedData / Internationalize / Build / Products / Debug -filelist / Users / UserName / WorkPlace / Internationalize / DerivedData / Internationalize / Build / Intermediates / Internationalise.build / Debug / Internationalise.build / Objects-normal / x86_64 / Internationalise.LinkFileList -Xlinker -rpath -Xlinker @executable_path /../ Frameworks -mmacosx-version-m in = 10.11 -Xlinker -no_deduplicate -stdlib = libc ++ -Xlinker -dependency_info -Xlinker /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Intermediates/Internationalise.build/Debug/Internationalise.build/Objects-normal/x86_64/ Internationalise_dependency_info.dat -o /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Products/Debug/Internationalise.app/Contents/MacOS/Internationalise



Undefined体系结构的符号x86_64:

_libintl_gettext,引用自:
Supporttextu中的gettext(char const *)

ld:symbol( s)找不到架构x86_64

clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)



操作系统:OS X



这里有什么问题?



谢谢



我尝试了什么:



我几乎不明白这个问题。


Error Message:

Ld DerivedData/Internationalise/Build/Products/Debug/Internationalise.app/Contents/MacOS/Internationalise normal x86_64
cd /Users/UserName/WorkPlace/Internationalise
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Products/Debug -F/Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Products/Debug -filelist /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Intermediates/Internationalise.build/Debug/Internationalise.build/Objects-normal/x86_64/Internationalise.LinkFileList -Xlinker -rpath -Xlinker @executable_path/../Frameworks -mmacosx-version-min=10.11 -Xlinker -no_deduplicate -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Intermediates/Internationalise.build/Debug/Internationalise.build/Objects-normal/x86_64/Internationalise_dependency_info.dat -o /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Products/Debug/Internationalise.app/Contents/MacOS/Internationalise

Undefined symbols for architecture x86_64:
"_libintl_gettext", referenced from:
gettext(char const*) in SupportLanguage.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

OS: OS X

What is the problem here?

Thanks

What I have tried:

I hardly understand the problem.

推荐答案

你不能以这种方式使用gettext。构造一些字符串对象并将其用作输入参数。
You cant use gettext in that manner. Construct some string object and use it as input param.


包含gettext.h后问题现在解决了。
The problem is solved now after including "gettext.h".


这篇关于使用gettext链接器错误进行国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆