리눅스에서 빌드 할 라이브러리를 얻고 있습니다. 이것은 Windows에서 빌드 및 작동하지만 Linux에서는 정적 라이브러리를 사용할 때 라이브러리에 해결되지 않은 기호가 표시됩니다. 다음과 같이 코드가 나타납니다 :이 클래스의 .cpp 파일 내부정의되지 않은 기호는 .cpp 파일에 정의되어 있지만
class MyClass : public AnotherClassRefCounded
{
public:
static bool queryInstance(MyClass **ppmyClass);
};
나는이 : 이제
#include "stdafx.h"
#include "MyClass.h"
MyClass* MyClass::m_pInstance = NULL;
bool MyClass::queryInstance(MyClass **myClass)
{
if(m_pInstance == NULL)
{
m_pInstance = new MyClass();
m_pInstance->incRef();
}
m_pInstance->incRef();
*myClass = m_pInstance;
return true;
}
나는 다음과 같은 출력을 얻을 libMyLib.a에 nm -Cu
를 실행하는 경우 :
[[email protected] libDebug]$ nm -Cu libMappingd.a | grep queryInstance
U AFewMoreScopes::MyClass::queryInstance(AFewMoreScopes::MyClass**)
을
내 시스템 정보는 다음과 같습니다 :
[[email protected] libDebug]$ cat /etc/redhat-release ; gcc --version
Red Hat Enterprise Linux Server release 6.1 (Santiago)
gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
저작권상의 이유로 동일한 코드를 게시 할 수 없습니다. 내 능력을 최대한 활용하여 코드를 재현했습니다. 정보가 누락되었다고 생각되면 주저하지 말고 요청하십시오. 빌드
UPDATE
예 :
...
g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W <DEFINE FLAGS> <INCLUDE FLAGS> -o MyClass.o MyClass.cpp
...
ar cqs libMappingd.a <all object files>
업데이트 0
이것은 매우 흥미 롭습니다. "MyClass에"에 대한 오브젝트 파일 내부 기호가 undefied되지 않습니다 그러나
MyClass.o:
<My Symbol Not Undefined>
당신이 오브젝트 파일의 또 다른 하나에 가면 :
<Other Object>.o:
...
U Scope::MyClass::queryInstance(Socpe::MyClass**)
갱신 1
g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o MyClass.o MyClass.cpp
g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o OtherClass.o OtherClass.cpp
rm -f libMappingd.a
ar cqs libMappingd.a <Other Objects> MyClass.o OtherClass.o
및
g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o OtherClass.o OtherClass.cpp
g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o MyClass.o MyClass.cpp
rm -f libMappingd.a
ar cqs libMappingd.a <Other Objects> OtherClass.o MyClass.o
차이가 없습니다. 다른 라이브러리에서는 아직 정의되지 않은 기호가 표시됩니다.
어떻게'libMappingd.a'을 만드나요? 명령 및 출력 결과를 게시하십시오. – jpalecek
cpp 파일에서 'MyClass'가 'RuntimeEnvironment'로 변경되는 이유는 무엇입니까? – BatchyX
Qt를 사용하여 정적 라이브러리를 작성하고 있습니다. 컴파일 문장에서 한 줄을 가져 오려면 잠깐만 기다려주세요. –