2014-02-11 3 views
1

msgpack 0.5.4 for C & C++을 다운로드하라는 메시지는 the instructions입니다.C 및 C++ 용 MessagePack 구현을 설치할 때 링커 오류가 발생했습니다.

On Windows, download source package from here and extract it. Open msgpack_vc8.vcproj or msgpack_vc2008 file and build it using batch build. It builds libraries in lib/ folder and header files in include/ folder.

You can build using command line as follows:

vcbuild msgpack_vc2008.vcproj 
dir lib  % DLL files are here 
dir include % header files are here 

vcbuild msgpack_vc2008.vcproj의은으로 MSBuild msgpack_vc8.vcxproj로 대체되었다. Visual Studio 2012를 사용하여이 프로젝트에 올바른 .vcxproj 파일을 변환했습니다. Visual Studio에서 일괄 빌드를 실행하고 MSBuild를 실행하면 동일한 결과가 발생하므로이 시점부터 두 가지 모두에 대해 설명하겠습니다.

프로젝트가 변환 된 후 프로젝트가 .dll이 아닌 .lib로 출력되도록 설정되어 있으므로 필요에 맞게 프로젝트를 변경했습니다.

...\microsoft visual studio 11.0\vc\include\stdint.h(8): error C2371: 'int8_t' : redefinition; different basic types 
...msgpack-0.5.4\src\msgpack\sysdep.h(23) : see declaration of 'int8_t' 

그래서 내가

사소한 문제를 해결
typedef signed __int8 int8_t; 

에 선

typedef __int8 int8_t; 

을 변경 : 컴파일 할 때 하나의 작은 오류가 발생했습니다. 그러나 그때 우리는 지금 내가있는 곳에 도착합니다. 이 링커 오류 : sysdep.h에서

: object.c에서

#define _msgpack_be16(x) ntohs(x) 
#define _msgpack_be32(x) ntohl(x) 

:

case MSGPACK_OBJECT_ARRAY: 
    { 
     int ret = msgpack_pack_array(pk, d.via.array.size); 
     if(ret < 0) { return ret; } 

     msgpack_object* o = d.via.array.ptr; 
     msgpack_object* const oend = d.via.array.ptr + d.via.array.size; 
     for(; o != oend; ++o) { 
      ret = msgpack_pack_object(pk, *o); 
      if(ret < 0) { return ret; } 
     } 

에서

objectc.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _msgpack_pack_array 
unpack.obj : error LNK2001: unresolved external symbol [email protected] 
objectc.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _msgpack_pack_array 
unpack.obj : error LNK2001: unresolved external symbol [email protected] 
...\msgpack-0.5.4\Debug\MessagePack.dll : fatal error LNK1120: 2 unresolved externals 

는이 오류의 일부를 검색 한 unpack.c :

static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_object* o) 
{ 
    o->type = MSGPACK_OBJECT_ARRAY; 
    o->via.array.size = 0; 
    o->via.array.ptr = (msgpack_object*)msgpack_zone_malloc(u->z, n*sizeof(msgpack_object)); 
    if(o->via.array.ptr == NULL) { return -1; } 
    return 0; 
} 

그게 내가 아는 전부입니다. .dll을 얻는 방법에 대한 또 다른 방법이 있다면 도움이 될 것입니다. 미리 감사드립니다. :)

답변

1

ntohl은 winsocket API 함수이므로 ws2_32.lib 라이브러리를 링크해야합니다.

이렇게하면 문제가 해결됩니다.