gcc에서 basic_string<wchar_t>를 사용하고 싶습니다.

iamslash의 이미지

gcc 3.3.2 입니다.

다음과 같은 코드가 있습니다.

#include <iostream>
#include <string>

using namespace std;

typedef basic_string<wchar_t> newstring;

int main()
{
        newstring a = L"hello world";

        return 0;
}

다음은 빌드룰입니다.

g++  -c   -o main.o main.cpp 
g++     -o a.out   main.o  

다음은 에러메시지입니다.

정의되지 않음                   첫번째 참조된 
 기호                       파일의
std::char_traits<wchar_t>::length(wchar_t const*)main.o
std::char_traits<wchar_t>::copy(wchar_t*, wchar_t const*, unsigned)main.o
ld: 치명적: 기호 참조 오류. a.out에 출력이 기록되지 않음
collect2: ld returned 1 exit status
make: *** [a.out] Error 1

위의 것을 제대로 링크까지 성공할려면 어찌해야 하나요?
정말 안되는 군요...
도와주세요...

dude7853의 이미지

저는 전혀 문제가 없더군요.
gcc 3.3.2에서 테스트 했습니다.
라이브러리 설정이 잘못되있는듯하네요.
glibc를 다시 설치해보시는게 좋을듯합니다.

sangu의 이미지

#include <iostream>
#include <string>
#include <wchar.h> //추가하세요.

using namespace std;

typedef basic_string<wchar_t> newstring;

int main()
{
        newstring a = L"hello world";

        return 0;
}

iamslash의 이미지

c++config.h 라는 것이 gcc build 할때 필요한 것입니까?
안에 살펴보니 wchar_t 를 쓸려면 _GLIBCPP_USE_WCHAR_T를 정의하라고
나와 있군요...

저의 경우는 solaris 5.8 입니다. pkgadd로 설치했는데... 어떻게 해야 하나요? gcc를 컴파일해서 설치해야 하는지... 지금 3.3.2 가 설치되있는데 문제가 없을지 궁금합니다.

yielding의 이미지

저도 같은 문제가 있네요

intel solaris 2.9
gcc 3.3
pkgadd로 gcc 인스톨 했습니다..

그리고 #include <wchar.h> 필요없습니다.

#include <string>
#include <iostream>

int main()
{ 
    wstring a=L"a";
    std::wcout << a;
}

가 문제없이 컴파일되야 합니다.

아마도 소스를 받아서 gcc를 컴파일 해야할 듯..

Life rushes on, we are distracted

iamslash의 이미지

gcc-3.3.2.tar.gz 를 받아서
libstdc++ 만 다시 설치했습니다.
libstdc++v3/include/bits/c++config 를 열어서
wchar_t 를 쓰겠다는 설정을 해주고 다시 빌드했더니 되는 군요...

빌드하는데 너무 오래걸렸습니다.

답변해주신분들께 감사드립니다.

yielding의 이미지

축하드립니다.

저도 gcc3.3.2.tar.gz 받고 있는데 열나 오래 걸리네요..

그리고 iamslash의 의미가 windows의 역슬래쉬(\)와 반대의
유닉스 계열의 슬래쉬 (/) 를 의미하는가요? '나는 리눅스가 좋다' 이런 의미인가요 ^^;

Life rushes on, we are distracted

fibonacci의 이미지

아바타로 추측컨데 GN'R의 기타리스트 slash 같은데요 그렇지 않은가요?

No Pain, No Gain.

winner의 이미지

왜 newstring 을 쓰시는지?

딴 얘기여서 죄송.

ssoo76의 이미지

libgcc-3.3-sol8-sparc-local.gz 이걸 깔면

libgcc_s.so libstdc++.a libstdc++.so libstdc++.so.5.0.4
libgcc_s.so.1 libstdc++.la libstdc++.so.5 sparcv9

./sparcv9:
libgcc_s.so.1 libstdc++.a libstdc++.so libstdc++.so.5.0.4
libgcc_s_sparcv9.so libstdc++.la libstdc++.so.5

이 파일들이 추가되는 군요...

아마도 이것들을 pkgadd로 설치하는것이 더 나을듯하네요.

세상은 하나..........

iamslash의 이미지

slash 는 기타리스트 이름입니다... ㅋㅋㅋ 근데 윗분중 역슬래시의 반대표현... 아주 멋있네요... 감동받았습니다....

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.