2014-05-09 2 views
1

Unix에 익숙한 사용자는 ldd 프로그램을 알고 있습니다. 주어진 실행 파일의 공유 라이브러리 종속성을 나열합니다. ntldd이라는 Windows 클론이 있습니다.WAF - ntldd - 정적 시스템 라이브러리를 연결할 수 없습니다.

gcc -fno-common -g -O3 -Wall -D_WIN32_WINNT=0x501 -c libntldd.c -o libntldd.o 
ar rs libntldd.a libntldd.o 
gcc -fno-common -g -O3 -Wall -L. ntldd.c -lntldd -limagehlp -o ntldd.exe 

빌드 스크립트가 작동합니다

ntldd 매우 간단한 빌드 스크립트가 있습니다.

WAF을 시험하기에 이상적인 작은 프로그램이라고 생각했습니다.

이것은 내가 생각 WScript와는 작동 것입니다 :

#! /usr/bin/env python 

from waflib import Logs 

APPNAME = "ntldd" 

top = "." 
out = "build" 

def options(ctx): 
    ctx.load("compiler_c") 

def configure(ctx): 
    ctx.load("compiler_c") 
    ctx.env.append_value("DEFINES", "_WIN32_WINNT=0x501") 

    if ctx.env.CC_NAME == "gcc": 
     ctx.env.CFLAGS = ["-g", "-fno-common", "-O3"] 
    ctx.check_cc(stlib = "imagehlp", linkflags = "-static") 

def build(ctx): 
    ctx.logger = Logs.make_logger("build/build.log", "build") 
    ctx.env.BINDIR = "binaries" 
    ctx.env.LIBDIR = ctx.env.BINDIR 

    # a C library 
    ctx\ 
    (
     features = ["c", "cstlib"], 
     source = "libntldd.c", 
     target = "_ntldd", 
    ) 

    # a C application 
    ctx\ 
    (
     features = ["c", "cprogram"], 
     source = "ntldd.c", 
     target = "ntldd", 
     use  = ["_ntldd", "imagehlp"], 
    ) 

을하지만 NO!

WAF reckons 실행 파일에 정적 라이브러리 imagehlp을 연결한다고 말한 적이 없습니다. build.log에서

: 그것은 MapAndLoadUnMapAndLoad을 찾을 수 없다는 불평 것을

['D:\\mingw-builds\\x64-4.8.1-posix-seh-rev5\\mingw64\\bin\\gcc.exe', '-Wl,--enable-auto-import', 'ntldd.c.2.o', '-o', 'C:\\Users\\Administrator\\Documents\\Projects\\ntldd\\build\\ntldd.exe', '-Wl,-Bstatic', '-L.', '-l_ntldd', '-Wl,-Bdynamic'] 
err: .\lib_ntldd.a(libntldd.c.1.o): In function `BuildDepTree': 
C:\Users\Administrator\Documents\Projects\ntldd\build/../libntldd.c:235: undefined reference to `__imp_MapAndLoad' 
C:\Users\Administrator\Documents\Projects\ntldd\build/../libntldd.c:441: undefined reference to `__imp_UnMapAndLoad' 
collect2.exe: error: ld returned 1 exit status 

참고; 두 함수 모두 imagehlp에 있습니다.

무슨 일 이니?

답변

2

당신은 당신이 (use은 다른 항목 같은 Waf 빌드에서 생산을 참조하는처럼 보이는) 연결하려는 기존의 시스템 정적 라이브러리를 나열 stlib 사전 키를 사용한다.

# a C application 
ctx\ 
(
    features = ["c", "cprogram"], 
    source = "ntldd.c", 
    target = "ntldd", 
    use  = ["_ntldd"], 
    stlib  = ["imagehlp"], 
) 

이 내용은 section 10.3 of the Waf Book에 있습니다. API 문서는 도움이되지 않았습니다.

+0

실제로'use ='에서 시스템 라이브러리를 참조 할 수 있지만'configure' 중에는 반드시 먼저 설정해야합니다. 'imagehlp'를 검사 할 때'uselib_store' 매개 변수가 누락되었습니다. – dilbert

관련 문제