microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.92k stars 6.33k forks source link

LNK2019 with Qwt with MSVC 2015 #30178

Open sebalaig opened 1 year ago

sebalaig commented 1 year ago

Describe the bug Trying to use a qwt under windows with MSVC lead to LNK2019 :

1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QwtPlotCurve::setSamples(class QVector<class QPointF> const &)" (__imp_?setSamples@QwtPlotCurve@@QEAAXAEBV?$QVector@VQPointF@@@@@Z) referenced in function main

Environment

To Reproduce Steps to reproduce the behavior:

  1. ./vcpkg install qwt:x64-windows
  2. Create a simple program main.cpp
    
    #include <qwt_plot_curve.h>

include

include

int main() { QwtPlotCurve curve;

QVector<QPointF> samples;
curve.setSamples(samples);

curve.show();

return 0;

}


test.pro

INCLUDEPATH += E:/vcpkg/installed/x64-windows/include/qwt LIBS += -LE:/vcpkg/installed/x64-windows/debug/lib LIBS += -lqwtd

QT += core gui

TARGET = test TEMPLATE = app

SOURCES += main.cpp


**Expected behavior**
The program compilation and link should be ok.

**Failure logs**

L'opération de génération a démarré... 1>------ Début de la génération : Projet : test, Configuration : Release x64 ------ 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(392,5): warning MSB8028: The intermediate directory (release) contains files shared from another project (bio_contamination.vcxproj). This can lead to incorrect clean and rebuild behavior. 1>Generate moc_predefs.h 1>main.cpp 1>main.obj : error LNK2019: unresolved external symbol "public: void __cdecl QwtPlotCurve::setSamples(class QVector const &)" (?setSamples@QwtPlotCurve@@QEAAXAEBV?$QVector@VQPointF@@@@@Z) referenced in function main 1>release\test.exe : fatal error LNK1120: 1 unresolved externals 1>Génération du projet "test.vcxproj" terminée -- ÉCHEC. ========== Génération : 0 a réussi, 1 a échoué, 0 à jour, 0 a été ignoré ==========


**Additional context**
The requested function exists in qwt_curve_plot.h (line 270) but analysing qwt.lib with command `dumpbin /exports qwtd.lib` indicates that the library contains the following symbols :  
              ?setSamples@QwtPlotBarChart@@QEAAXPEAV?$QwtSeriesData@VQPointF@@@@@Z (public: void __cdecl QwtPlotBarChart::setSamples(class QwtSeriesData<class QPointF> *))
              ?setSamples@QwtPlotCurve@@QEAAXAEBV?$QList@M@@0@Z (public: void __cdecl QwtPlotCurve::setSamples(class QList<float> const &,class QList<float> const &))
              ?setSamples@QwtPlotCurve@@QEAAXAEBV?$QList@M@@@Z (public: void __cdecl QwtPlotCurve::setSamples(class QList<float> const &))
              ?setSamples@QwtPlotCurve@@QEAAXAEBV?$QList@N@@0@Z (public: void __cdecl QwtPlotCurve::setSamples(class QList<double> const &,class QList<double> const &))
              ?setSamples@QwtPlotCurve@@QEAAXAEBV?$QList@N@@@Z (public: void __cdecl QwtPlotCurve::setSamples(class QList<double> const &))
              ?setSamples@QwtPlotCurve@@QEAAXAEBV?$QList@VQPointF@@@@@Z (public: void __cdecl QwtPlotCurve::setSamples(class QList<class QPointF> const &))
              ?setSamples@QwtPlotCurve@@QEAAXPEAV?$QwtSeriesData@VQPointF@@@@@Z (public: void __cdecl QwtPlotCurve::setSamples(class QwtSeriesData<class QPointF> *))
              ?setSamples@QwtPlotCurve@@QEAAXPEBM0H@Z (public: void __cdecl QwtPlotCurve::setSamples(float const *,float const *,int))
              ?setSamples@QwtPlotCurve@@QEAAXPEBMH@Z (public: void __cdecl QwtPlotCurve::setSamples(float const *,int))
              ?setSamples@QwtPlotCurve@@QEAAXPEBN0H@Z (public: void __cdecl QwtPlotCurve::setSamples(double const *,double const *,int))
              ?setSamples@QwtPlotCurve@@QEAAXPEBNH@Z (public: void __cdecl QwtPlotCurve::setSamples(double const *,int))

The function taking a qvector is not in the library
sebalaig commented 1 year ago

Hi, can anyone reproduce the bug from the description ? Is it a problem on my side ? Thank you in advance for feedback.

Cheney-W commented 1 year ago

I can't reproduce this issue in my side with latest vcpkg 2023-06-07-25da717d8191c36743f0f8a25eecfa9ff6f8d195 and VS2022 17.6.1.

After run .\vcpkg.exe integrate install, I also performed the following actions:

  1. Add below pathes into the include directories:
    F:\vcpkg\installed\x64-windows\include\Qt6
    F:\vcpkg\installed\x64-windows\include\Qt6\QtCore
    F:\vcpkg\installed\x64-windows\include\qwt
  2. Add /Zc:__cplusplus and /std:c++17 compile option.

image

If you have been encountering this issue consistently on VS2015, you may consider using a higher version of Visual Studio.

github-actions[bot] commented 1 year ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

cmdrf commented 1 year ago

I have the same problem with VS2019. However, I'm trying to use Qwt in a Qt 5 application, and now I noticed that Qwt links against Qt 6. This could be the problem.

More info and reasoning in #22012. Apparently one could use an "overlay port" to solve this.

github-actions[bot] commented 1 year ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

github-actions[bot] commented 1 year ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

github-actions[bot] commented 11 months ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.