0

静态错误:

   in test1.dll:
    xxx.h
    class AFX_EXT_CLASS CTest1
    {
        static int num;
    }

    xxx.cpp
    int CTest1::num = 0;

    in a cpp of test2.dll: test2 is dependent test1.dll
    ...
    int i = CTest1::num;
    ...

    in a cpp of App: App is dependent test1.dll & test2.dll
    ...
    int i = CTest1::num;
    ...

在 test2.dll 中,静态上的“未解析的外部符号”:CTest1::num。但在App中,没问题。

顺便说一句:如果我使用 CTest1 的其他功能,没问题。

帮帮我,非常感谢。

4

1 回答 1

0

编译器正在剥离符号。你可以试试__declspecimport。您还可以尝试extern使用该变量并在另一个项目中创建人工引用。

于 2013-04-29T15:43:43.240 回答