簡體   English   中英

Windows上QtCreator中的鏈接問題

[英]Linking issue in QtCreator on Windows

我需要在QtCreator中使用端口音頻。 但是我無法使鏈接正常工作。

我有一個非常簡單的主體:

#include "portaudio.h"
#include <iostream>

int main(int, char *[])
{
     std::cout << Pa_GetErrorText(0) << std::endl;
     return 0;
}

Il將此片段放在帶有portaudio.lib的文件夾中。 在Visual Studio 2012中,它可以很好地進行編譯和執行(在添加包含路徑和庫之后)。

在QtCreator中,我嘗試添加到.pro:

LIBS += -L$$PWD -lportaudio

要么:

LIBS += $$PWD/portaudio.lib

所以,我是迷途的小人。 我對Windows構建環境不是很熟悉。

我添加了編譯輸出。

link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\test_portaudio.exe.embed.manifest /OUT:debug\test_portaudio.exe
@C:\Users\victor\AppData\Local\Temp\test_portaudio.exe.7044.16.jom
main.obj : error LNK2019: external symbol Pa_GetErrorText referenced in function main
debug\test_portaudio.exe : fatal error LNK1120: 1 externes non résolus
jom: C:\Users\victor\Documents\build-test_portaudio-Desktop_Qt_5_2_0_MSVC2012_64bit-Debug\Makefile.Debug [debug\test_portaudio.exe] Error 1120
jom: C:\Users\victor\Documents\build-test_portaudio-Desktop_Qt_5_2_0_MSVC2012_64bit-Debug\Makefile [debug] Error 2
09:05:25: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project test_portaudio (kit: Desktop Qt 5.2.0 MSVC2012 64bit)
When executing step 'Make'

感謝您的幫助,Vhb

編輯:這是.pro文件:

QT       += core
QT       -= gui
TARGET = test_portaudio
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
INCLUDEPATH += $$PWD/../portaudio/include
LIBS += -L$$PWD -lportaudio
SOURCES += main.cpp

清單文件:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='asInvoker' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*' />
    </dependentAssembly>
  </dependency>
</assembly>

我正在使用帶有qtCreator 3.0和Visual Studio 2012的qt 5.2.0。

您的鏈接器命令似乎尚未實現更改:

鏈接/ NOLOGO / DYNAMICBASE / NXCOMPAT / DEBUG / SUBSYSTEM:CONSOLE“ / MANIFESTDEPENDENCY:type ='win32'name ='Microsoft.Windows.Common-Controls'version ='6.0.0.0'publicKeyToken ='6595b64144ccf1df'language =' ''處理器體系結構=' '“ / MANIFEST /MANIFESTFILE:debug\\test_portaudio.exe.embed.manifest /OUT:debug\\test_portaudio.exe

如您所見,其中沒有對portaudio庫的引用。 因此,得到一個未定義的引用就不足為奇了。

您可能忘記了顯式使用execute qmake選項來重新運行qmake。 一旦完成,它將起作用。

在不提供更多上下文的情況下很難告訴更多信息,但是您也可以使用qmake在命令行中再次檢查此操作。 它在這里工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM