开发者

Windows Linking

I'm attempting to use SCons to compile and link a simple Windows program. I have two files that need compilation, httprequest.cpp and curltest.cpp. First, I'd like to make a library from the httprequest.*pp files. These files rely on the libcurl.lib library which is also in my source code.

Once this is compiled I then attempt to compile the curltest.cpp into an .exe (also relying on the libcurl.lib library). However, I keep getting errors like:

httpreq.lib(httprequest.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_setopt r开发者_如何学Goeferenced in function "public: __thiscall HTTPRequest::HTTPRequest(void)" (??0HTTPRequest@@QAE@XZ)

Despite explicitly linking to the libcurl.lib (which I've confirmed -- using nm -- has the available methods __curl_easy_setopt and the like) I'm encountering problems when the httpreq.lib tries to find the libcurl methods.

How can I link in the libcurl.lib to both the httpreq library and the curltest executable without problems?

EDIT: This is my SConstruct file which builds and links just fine under Ubuntu 11.04.

httpreq = 'src//httprequest.cpp'
StaticLibrary('httpreq', httpreq)
env = Environment(
                    CPPPATH = ['#//include//curl',
                                '#//src'
                                ],

                    LIBPATH = ['#//bin',
                                '#//'
                                ],

                    LIBS = ['libcurl',
                            'httpreq'
                            ]
                )
curltest = ['src//curltest.cpp']
env.Program('test', curltest)


This seems to be a question answered in the libcurl FAQ already.

The key is that to use a static libcurl lib on windows, you must define CURL_STATICLIB at compile time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜