在 Windows 上使用 Clang 构建 wxWidgets 时对 std::streambuf 方法的未定义引用

发布于 2025-01-16 16:43:34 字数 4784 浏览 1 评论 0原文

我一直在尝试使用 Clang(使用 MSVC 库)构建我的应用程序(使用 wxWidgets)。但我不断收到这些链接错误。我曾经使用 minGW 构建应用程序,并且运行得很好。

这些是错误:

graphics.o : error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::setp(char *,char *,char *)" (__imp_?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z) referenced in function "protected: virtual in
t __cdecl std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::overflow(int)" (?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z)
graphics.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::locale __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::getloc(void)const " (__imp_?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ) referenced in function "public: clas 
s std::basic_filebuf<char,struct std::char_traits<char> > * __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::open(char const *,int,int)" (?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z)
shaders.o : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::locale __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::getloc(void)const " (__imp_?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ)
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)
graphics.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::snextc(void)" (__imp_?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ) referenced in function "class std::basic_istream<char,struct std::c 
har_traits<char> > & __cdecl std::getline<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_istream<char,struct std::char_traits<char> > &&,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char)" (??$getline@DU?$char_traits@D@std@@V?$all 
ocator@D@2@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@$$QEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z)
shaders.o : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::snextc(void)" (__imp_?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ)
make: *** [main.exe] Error 1120
shaders.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::fpos<struct _Mbstatet> __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::pubseekoff(__int64,int,int)" (__imp_?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@U_Mbstatet@@@2 
@_JHH@Z) referenced in function "public: class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::basic_istream<char,struct std::char_traits<char> >::seekg(__int64,int)" (?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z)
shaders.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sgetn(char *,__int64)" (__imp_?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z) referenced in function "public: class std::basic_ 
istream<char,struct std::char_traits<char> > & __cdecl std::basic_istream<char,struct std::char_traits<char> >::read(char *,__int64)" (?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z)
.\build\main.exe : fatal error LNK1120: 5 unresolved externals

我有 wxWidgets v3.1.5、Clang v13.0.1 和 MSVC v143

我正在使用这个 makefile:

CXX := clang++
CXXFLAGS := -Winvalid-pch -Wall -Wextra --std=c++17
CXXFLAGS := -DWXUSINGDLL -D_UNICODE -D__WXMSW__ -DNDEBUG

OUTPUT := main.exe

SRC_DIR = ./src
BUILD_DIR = ./build

CXXFLAGS += -isystem./include/msvc -isystem./include
LDFLAGS := -L./lib/vc_x64_dll
LDFLAGS += -L./lib/glew
LDFLAGS +=  -lopengl32
LDFLAGS += -lglew32

SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
OBJS := $(SOURCES:%.cpp=%.o)

DEPS := $(wildcard $(SRC_DIR)/*.hpp)

all: $(OUTPUT)

$(OUTPUT): $(OBJS)
    @echo linking...
    @$(CXX) -o ./build/$@ $(OBJS) $(LDFLAGS)

.PHONY: all

%.o: %.cpp $(DEPS)
    @echo $(CXX) -c $<
    @$(CXX) $< -c -o $@ $(CXXFLAGS)

我已经在 Windows 11 和 Windows 10 上尝试过这个,两者都有相同的结果。

I've been trying to build my app (with wxWidgets) using Clang (with MSVC libraries). But I keep getting these linking errors. I used to build the app using minGW and it worked just fine.

These are the errors:

graphics.o : error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::setp(char *,char *,char *)" (__imp_?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z) referenced in function "protected: virtual in
t __cdecl std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::overflow(int)" (?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z)
graphics.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::locale __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::getloc(void)const " (__imp_?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ) referenced in function "public: clas 
s std::basic_filebuf<char,struct std::char_traits<char> > * __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::open(char const *,int,int)" (?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z)
shaders.o : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::locale __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::getloc(void)const " (__imp_?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ)
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)
graphics.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::snextc(void)" (__imp_?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ) referenced in function "class std::basic_istream<char,struct std::c 
har_traits<char> > & __cdecl std::getline<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_istream<char,struct std::char_traits<char> > &&,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char)" (??$getline@DU?$char_traits@D@std@@V?$all 
ocator@D@2@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@$QEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z)
shaders.o : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::snextc(void)" (__imp_?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ)
make: *** [main.exe] Error 1120
shaders.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::fpos<struct _Mbstatet> __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::pubseekoff(__int64,int,int)" (__imp_?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@U_Mbstatet@@@2 
@_JHH@Z) referenced in function "public: class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::basic_istream<char,struct std::char_traits<char> >::seekg(__int64,int)" (?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z)
shaders.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sgetn(char *,__int64)" (__imp_?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z) referenced in function "public: class std::basic_ 
istream<char,struct std::char_traits<char> > & __cdecl std::basic_istream<char,struct std::char_traits<char> >::read(char *,__int64)" (?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z)
.\build\main.exe : fatal error LNK1120: 5 unresolved externals

I have wxWidgets v3.1.5, Clang v13.0.1 and MSVC v143

I am using this makefile:

CXX := clang++
CXXFLAGS := -Winvalid-pch -Wall -Wextra --std=c++17
CXXFLAGS := -DWXUSINGDLL -D_UNICODE -D__WXMSW__ -DNDEBUG

OUTPUT := main.exe

SRC_DIR = ./src
BUILD_DIR = ./build

CXXFLAGS += -isystem./include/msvc -isystem./include
LDFLAGS := -L./lib/vc_x64_dll
LDFLAGS += -L./lib/glew
LDFLAGS +=  -lopengl32
LDFLAGS += -lglew32

SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
OBJS := $(SOURCES:%.cpp=%.o)

DEPS := $(wildcard $(SRC_DIR)/*.hpp)

all: $(OUTPUT)

$(OUTPUT): $(OBJS)
    @echo linking...
    @$(CXX) -o ./build/$@ $(OBJS) $(LDFLAGS)

.PHONY: all

%.o: %.cpp $(DEPS)
    @echo $(CXX) -c 
lt;
    @$(CXX) 
lt; -c -o $@ $(CXXFLAGS)

I've tried this on Windows 11 as well as Windows 10, both with the same outcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文