我做了一个静态库,其中包含了一个类,类外有几个变量和函数,类和类内的成员可以访问,但类外的变量和函数不知如何访问。还有编译调用库的可执行文件时有如下的警告,如何消除警告。
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
谢谢了!
...全文
23715打赏收藏
初来乍到,希望大家多多帮忙呀!lib中的函数如何调用?
我做了一个静态库,其中包含了一个类,类外有几个变量和函数,类和类内的成员可以访问,但类外的变量和函数不知如何访问。还有编译调用库的可执行文件时有如下的警告,如何消除警告。 LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library 谢谢了!
In my app:
void __declspec(dllimport) SetPubint(iage);
m_LibClass.SetAge(int __declspec(dllimport) GetPubint() +10);
In the Static library:
int __declspec(dllexport) m_pubint;
int __declspec(dllexport) GetPubint()
{
return m_pubint;
}
void __declspec(dllexport) SetPubint(int pubint)
{
m_pubint=pubint;
}
In the debug output box:
..\MyAppDlg.cpp(183) : error C2182: 'SetPubint' : illegal use of type 'void'
..\MyAppDlg.cpp(183) : error C2491: 'SetPubint' : definition of dllimport data not allowed
..\MyAppDlg.cpp(183) : error C2205: 'SetPubint' : cannot initialize extern variables with block scope
..\MyAppDlg.cpp(184) : error C2144: syntax error : missing ')' before type 'int'
..\MyAppDlg.cpp(184) : error C2660: 'SetAge' : function does not take 0 parameters
..\MyAppDlg.cpp(184) : error C2059: syntax error : ')'
Error executing cl.exe.