Sun WorkShop 6 update 2 C++ 5.3 에서 링크옵션에 대해서

yoway의 이미지

이번에 SUN 쪽으로 포팅을 하던중에 링크에서 문제가 생겨서 질문을 올리게 됐습니다.
일단 간단하게 3개의 파일로 테스트 소스를 만들었습니다.

b.h

#include <vector>
#include <string>

class MyStrVec
{
public:
	MyStrVec();
	virtual ~MyStrVec();
	
	void push( std::string s );
	std::string get(int i);
	void clear();
	int size();

private:
	std::vector<std::string> v_;
}; 

class foo
{
public:
	foo() {};
	virtual ~foo() {};

	int getValue() { return 23; };
};

b.cpp

#include "b.h"

using std::string;

MyStrVec::MyStrVec()
{
}

MyStrVec::~MyStrVec()
{
}

void MyStrVec::push(string s )
{
	v_.push_back( s );
}

string MyStrVec::get(int i)
{
	return v_[i];
}

void MyStrVec::clear()
{
	v_.clear();
}

int MyStrVec::size()
{
	return (int)(v_.size());
}

위의 b.h와 b.cpp 는 libB.a 를 만든다고 생각하시면 됩니다.

a.cpp

#include <iostream>
#include <vector>
#include <string>

using std::cout;
using std::endl;
using std::vector;
using std::string;

#include "b.h"

int main()
{
	vector<string> v;
	v.push_back("aaaa");
	v.push_back("bbbb");
	v.push_back("cccc");

	for( vector<string>::iterator i = v.begin(); i != v.end(); i++ )
	{
		cout<<*i<<endl;
	}

	MyStrVec m;
	m.push("yoway");
	cout<<m.get(0)<<endl;

	foo f;
	cout<<f.getValue()<<endl;

	return 0;
}

위의 a.cpp 는 main 함수가 있고 위에서 만든 libB.a를 사용하신다고 생각하시면 됩니다.

make 파일도 만들었습니다.

Quote:

CXX=CC
CXXFLAGS=-g -D_DEBUG -D_SUN_CC_
LINKS=.

bin: test

clean:
rm -f *.o
rm -f libB.a
rm -f out

.SUFFIXES:
.SUFFIXES: .a .o .c .cpp

.cpp.o:
$(CXX) $(CXXFLAGS) -c $*.cpp

LIB_B_OBJ=b.o

libB.a: $(LIB_B_OBJ)
$(AR) -cr $@ $(LIB_B_OBJ)
ranlib $@

MAIN_OBJ=a.o

test: libB.a $(MAIN_OBJ)
$(CXX) -o out $(MAIN_OBJ) -L$(LINKS) -lB

a.o: a.cpp
b.o: b.cpp b.h

이제 본론으로 들어가서..
cpp 파일은 CC -g 로 컴파일 했습니다.
libB.a 는
ar -cr XX
와 ranlib 으로 정적라이브러리 화 시켰습니다.
그리고 실행파일인 out 은
CC -o out XX
로 생성할려는중!
a.o 와 libB.a를 링크할때 에러가 나는 겁니다.

Quote:

__type_1 std::copy<std::basic_string<char,std::char_traits<char>,std::allocator<char> >*,std::basic_
string<char,std::char_traits<char>,std::allocator<char> >*>(__type_0,__type_0,__type_1) ./libnewmat.
a(b.o)

에러는 이렇구요.

a.cpp 부분에서

Quote:

MyStrVec m;
m.push("yoway");
cout<<m.get(0)<<endl;

요 부분을 주석처리하면 문제없이 처리 됩니다.
libB.a중에서 stl 을 사용하는 부분이죠.

이 코드 밑의 foo 클래스는 똑같이 libB.a 에 있지만 stl 이나 c/c++ 라이브러리를 사용하지 않는 부분이라 그런지 문제가 생기지 않습니다.
일단 IBM-AIX 에서도 테스트를 해봤습니다만.. 별 문제 없이 컴파일이 되더군요.

제 생각에는 컴파일이나 링크옵션에 문제가 있는것 같습니다..
그럼 답변 좀 부탁드리겠습니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.