Microsoft Visual Studio '08으로 libpng를 컴파일 할 때 "Error LNK2005 :"(이미 정의 된 stdlib 함수)를 피하는 방법?

StackOverflow https://stackoverflow.com/questions/1937937

문제

(내가 이것을하려고하는 이유 : 나는 Windows에서 Libpng에 사전 제작 된 바이너리를 사용하는 데 운이 좋지 않았으므로 (많은 시간의 시행 착오에도 불구하고) 지금 직접 컴파일하려고 노력하고 있습니다. 이 유용한 블로그 게시물 이와 관련하여 Microsoft Visual Studio 2008 프로젝트 파일로 완성되었지만 불행히도 여전히 사용할 수 없었습니다.)

발견 된 zlib 이진에 연결할 때 성공적으로 컴파일됩니다. 여기, 그러나 테스트 파일에 연결하려고 할 때 다음을받습니다.

    C:\Documents and Settings\Administrator\My Documents>cl "C:\Documents and Settin
    gs\Administrator\My Documents\test.c" "C:\Documents and Settings\Administrator\M
    y Documents\libpng.lib" -I "C:\Documents and Settings\Administrator\My Documents\include"

    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
    Copyright (C) Microsoft Corporation.  All rights reserved.

    test.c
    Microsoft (R) Incremental Linker Version 9.00.30729.01
    Copyright (C) Microsoft Corporation.  All rights reserved.

    /out:test.exe
    test.obj
    "C:\Documents and Settings\Administrator\My Documents\libpng.lib"
    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _abort already defined in LIBCMT.lib(
    abort.obj)
    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _fread already defined in LIBCMT.lib(
    fread.obj)
    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _malloc already defined in LIBCMT.lib
    (malloc.obj)
    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _free already defined in LIBCMT.lib(f
    ree.obj)
    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: ___iob_func already defined in LIBCMT
    .lib(_file.obj)
    LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
    se /NODEFAULTLIB:library
    test.exe : fatal error LNK1169: one or more multiply defined symbols found

이 오류를 고치는 방법에 대해 누군가가 빛을 발할 수 있습니까?

도움이 되었습니까?

해결책

문제는 두 프로젝트 중 하나가 멀티 스레드 DLL 다른 사람이 사용하는 동안 멀티 스레드 프로젝트 속성 -> 구성 속성 -> C/C ++ -> 코드 생성.

나에게 여러 번 일어났다.

릴리스 빌드 및 가능한 각 조합 (디버그, 디버그 등)에 대해 해당 설정을 "동기화"해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top