Results 1 to 3 of 3

Thread: Problems linking multiple dependent libraries involving XML schema and Cstrings

  1. #1
    Join Date
    Aug 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Problems linking multiple dependent libraries involving XML schema and Cstrings

    I'm attempting to incorporate an SDK into my project and wanted to use Qt for the gui development. According to SDK documentation: " Our VC++ SDK requires the Visual C++ 2010 Redistributable package from Microsoft and the Code Synthesis XSD compiler and libraries from Code Synthesis." So first i installed XSD(version 3.3) and added the various necessary dependencies in visual studio 10 and successfully built the examples. I then installed the Qt 5.5 plugin(also later installed the Qt5.5_msvc10 build...both lead to the same error).

    The problem i keep encountering is that while I get a successful build just using the functions and classes from the SDK, any attempt to do anything with it(access elements of a std::list, for example) produces the following error:
    LNK2019: unresolved external symbol "__declspec(dllimport) public: class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > __thiscall CAccount::GetAccountId(void)" (__imp_?GetAccountId@CAccount@@QAE?AV?$CStringT@_W V?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL @@XZ) referenced in function "private: void __thiscall MainWindow:n_pushButton_2_clicked(void)" (?on_pushButton_2_clicked@MainWindow@@AAEXXZ)

    For Example:
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <QtCore>
    6. #include "ladderwindow.h"
    7. #include "OAuth/OAuthSDK.h"
    8. #include "Accounts/AccountSDK.h"
    9. #include "Market/MarketSDK.h"
    10. #include "Order/OrderSDK.h"
    11. #include <QtNetwork>
    12.  
    13.  
    14.  
    15. namespace Ui {
    16. class MainWindow;
    17. }
    18.  
    19. class MainWindow : public QMainWindow
    20. {
    21. Q_OBJECT
    22.  
    23. public:
    24. explicit MainWindow(QWidget *parent = 0);
    25. ~MainWindow();
    26.  
    27. private slots:
    28. void on_pushButton_2_clicked();
    29.  
    30. private:
    31. CAccountSDK *acc;
    32. AccountList alist;
    33.  
    34. };
    35.  
    36. #endif // MAINWINDOW_H
    37.  
    38. //Mainwindow.cpp//
    39. #include "mainwindow.h"
    40. #include "ladderwindow.h"
    41. #include "ui_mainwindow.h"
    42.  
    43. #include <QCoreApplication>
    44. #include <QString>
    45.  
    46. #include <OAuth/OAuthSDK.h>
    47. #include <Accounts/AccountSDK.h>
    48. #include <Market/MarketSDK.h>
    49. #include <Order/OrderSDK.h>
    50.  
    51. #include <QUrl>
    52. #include <QUrlQuery>
    53. #include <QWebElement>
    54. #include <QDebug>
    55.  
    56. MainWindow::MainWindow(QWidget *parent) :
    57. QMainWindow(parent),
    58. ui(new Ui::MainWindow)
    59. {...}
    60.  
    61. void MainWindow::on_pushButton_2_clicked()
    62. {
    63. try {
    64. AuthCode = ui->lineEdit->text();
    65. mAuth->GetAccessToken(*client,AuthCode.toStdString());
    66. try {
    67. acc = new CAccountSDK(*client);
    68.  
    69. alist = acc->GetAccountList(); //[B]Builds, application output window streams a XML of the response[/B]
    70.  
    71. std::wstring mangledstringtest(CString("WTF"));
    72. ui->textBrowser->append(QString::fromStdWString(mangledstringtest));
    73.  
    74. //[B] This and all other attempts to do anything with alist fails to compile[/B]
    75. foreach(CAccount i, alist)
    76. {
    77. //ui->textBrowser->append(QString::fromStdString(i.GetAccountId()));
    78. //USES_CONVERSION
    79. ui->textBrowser->append(QString::fromWCharArray((i.GetAccountId().GetBuffer())));
    80. //std::wstring mangledstring(CString(i.GetAccountId()));
    81. //ui->textBrowser->append(QString::fromStdWString(mangledstring));
    82. }
    83. } catch (...) {}
    84. ladder = new ladderwindow(this);
    85. ladder->show();
    86. }
    87. catch (...) {}
    88. }
    To copy to clipboard, switch view to plain text mode 

    Since the calls I make are from the libraries from the SDK, my thought is that perhaps a) i haven't properly specified the paths to the necessary dlls from the codesynthesis xsd installation or b) i need to make some modifications and/or includes of various string related header files included with the SDK.
    Heres a portion of my .pro

    Qt Code:
    1. QT += core gui
    2. QT += network
    3. QT += webkitwidgets network widgets
    4.  
    5. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    6.  
    7. TARGET = Etrader
    8. TEMPLATE = app
    9.  
    10. #PRECOMPILED_HEADER = stdafx.h
    11.  
    12. SOURCES += main.cpp\
    13. automain.cpp \
    14. mainwindow.cpp \
    15. ladderwindow.cpp
    16.  
    17. HEADERS += automain.h \
    18. OAuth/OAuthSDK.h \
    19. Accounts/AccountSDK.h \
    20. Market/MarketSDK.h \
    21. Order/OrderSDK.h \
    22. mainwindow.h \
    23. ladderwindow.h
    24.  
    25. FORMS += automain.ui \
    26. mainwindow.ui \
    27. ladderwindow.ui
    28.  
    29. DEFINES += _AFXDLL
    30.  
    31. INCLUDEPATH += "C:/ProgramFiles(x86)/CodeSynthesisXSD3.3/xerces-c-3.1.1/src"
    32. INCLUDEPATH += "C:/ProgramFiles(x86)/CodeSynthesisXSD3.3/bin"
    33. INCLUDEPATH += "C:/ProgramFiles(x86)/CodeSynthesisXSD3.3/include"
    34.  
    35. win32: LIBS += -L$$PWD/../../Program Files (x86)/CodeSynthesis XSD 3.3/lib/vc-10.0/ -lxerces-c_3
    36.  
    37. INCLUDEPATH += $$PWD/../../Program Files (x86)/CodeSynthesis XSD 3.3/lib/vc-10.0
    38. DEPENDPATH += $$PWD/../../Program Files (x86)/CodeSynthesis XSD 3.3/lib/vc-10.0
    39.  
    40. win32: LIBS += -L$$PWD/../../Program Files (x86)/CodeSynthesis XSD 3.3/lib/vc-10.0/ -lxerces-c_3D
    41.  
    42. INCLUDEPATH += $$PWD/../../Program Files (x86)/CodeSynthesis XSD 3.3/lib/vc-10.0
    43. #DEPENDPATH += $$PWD/../../Program Files (x86)/CodeSynthesis XSD 3.3/lib/vc-10.0
    44.  
    45.  
    46. #1 of 5 SDK libs...
    47. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/release/ -lETCommon
    48. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/debug/ -lETCommon
    49. else:unix:!macx: LIBS += -L$$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/ -lETCommon
    50.  
    51. INCLUDEPATH += $$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/debug
    52. DEPENDPATH += $$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/debug
    53.  
    54. win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/release/libETCommon.a
    55. else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/debug/libETCommon.a
    56. else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/release/ETCommon.lib
    57. else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/debug/ETCommon.lib
    58. else:unix:!macx: PRE_TARGETDEPS += $$PWD/../build-Etrader-Desktop_Qt_5_5_0_MSVC2010_32bit-Debug/libETCommon.a
    To copy to clipboard, switch view to plain text mode 

    And here potentially relevant portions of the stdafx and headers related to CStringT that seem to be a problem:

    Qt Code:
    1. //stdafx.h
    2. #pragma once
    3.  
    4. #ifndef VC_EXTRALEAN
    5. #define VC_EXTRALEAN
    6. #endif
    7. typedef std::basic_string<TCHAR> tstring;
    8. #define SIZEOF(x) (sizeof(x)/sizeof(*x))
    9.  
    10. #define COMMON_LIBRARY_EXPORT
    11.  
    12. #include "common/Common/StringUtil.h"
    13. #include "common/Common/Base64Coder.h"
    14.  
    15.  
    16. //StringUtil.h
    17. #ifndef _STRINGUTIL_H_INCLUDED_
    18. #define _STRINGUTIL_H_INCLUDED_
    19. #include "CommonDefs.h"
    20. #include <stdlib.h>
    21. #include <string>
    22. #include <iostream>
    23. #include <stdlib.h>
    24. #include <string>
    25.  
    26. #include "atlbase.h"
    27. #include "atlstr.h"
    28. #include "comutil.h"
    29.  
    30. using namespace std;
    31.  
    32. #ifdef _UNICODE
    33. #define TCHARToUTF8 WideToUTF8
    34. #define UTF8ToTCHAR UTF8ToWide
    35. #define TCHARToWide
    36. #define WideToTCHAR
    37. #define TCHARToMB WideToMB
    38. #define MBToTCHAR MBToWide
    39. #else
    40. #define TCHARToUTF8 ANSIToUTF8
    41. #define UTF8ToTCHAR UTF8ToANSI
    42. #define TCHARToWide MBToWide
    43. #define WideToTCHAR WideToMB
    44. #define TCHARToMB
    45. #define MBToTCHAR
    46. #endif
    47.  
    48. class CStringUtil
    49. {
    50. public:
    51. CStringUtil(void);
    52. virtual ~CStringUtil(void);
    53.  
    54. void Split(const tstring& str, std::vector<tstring>& out, TCHAR sep, bool includeEmpty);
    55. tstring GetWord(const tstring& str, unsigned index, bool getRest = false);
    56.  
    57. inline bool Compare(const tstring& one, const tstring& two, bool caseSensitive)
    58. {
    59. return caseSensitive ? (one == two) : (_tcsicmp(one.c_str(), two.c_str()) == 0);
    60. };
    61. };
    62.  
    63. #endif//_STRINGUTIL_H_INCLUDED_
    64.  
    65. //CBase64Coder.h
    66. #pragma once
    67.  
    68. #ifdef _AFXDLL
    69. #include <afx.h>
    70. typedef CString String;
    71. #else
    72. #include <windows.h>
    73. #include <string>
    74. typedef std::string String;
    75. #endif
    76.  
    77. #ifndef CBase64Coder_HEADER
    78. #define CBase64Coder_HEADER
    79. #endif
    80.  
    81. class CBase64Coder
    82. {
    83. private:
    84. // Internal bucket class.
    85. class TempBucket
    86. {
    87. public:
    88. BYTE nData[4];
    89. BYTE nSize;
    90. void Clear() { ::ZeroMemory(nData, 4); nSize = 0; };
    91. };
    92.  
    93. PBYTE m_pDBuffer;
    94. PBYTE m_pEBuffer;
    95. DWORD m_nDBufLen;
    96. DWORD m_nEBufLen;
    97. DWORD m_nDDataLen;
    98. DWORD m_nEDataLen;
    99.  
    100. public:
    101. CBase64Coder();
    102. virtual ~CBase64Coder();
    103.  
    104. public:
    105. virtual void Encode(const PBYTE, DWORD);
    106. virtual void Decode(const PBYTE, DWORD);
    107. virtual void Encode(LPCSTR sMessage);
    108. virtual void Decode(LPCSTR sMessage);
    109.  
    110. virtual LPCSTR DecodedMessage() const;
    111. virtual LPCSTR EncodedMessage() const;
    112.  
    113. virtual void AllocEncode(DWORD);
    114. virtual void AllocDecode(DWORD);
    115. virtual void SetEncodeBuffer(const PBYTE pBuffer, DWORD nBufLen);
    116. virtual void SetDecodeBuffer(const PBYTE pBuffer, DWORD nBufLen);
    117.  
    118. protected:
    119. virtual void _EncodeToBuffer(const TempBucket &Decode, PBYTE pBuffer);
    120. virtual ULONG _DecodeToBuffer(const TempBucket &Decode, PBYTE pBuffer);
    121. virtual void _EncodeRaw(TempBucket &, const TempBucket &);
    122. virtual void _DecodeRaw(TempBucket &, const TempBucket &);
    123. virtual BOOL _IsBadMimeChar(BYTE);
    124.  
    125. static char m_DecodeTable[256];
    126. static BOOL m_Init;
    127. void _Init();
    128.  
    129. };
    To copy to clipboard, switch view to plain text mode 

    I've tried switching around the order in which ive added the various Libraries as well changing between static and dynamic with no luck. Ive searched and tried a whole bunch of different means of intermediate conversions to see if i could convert the cstring into something i could then convert to a Qstring but anything i've tried still produces the linker error. I've been stuck on this for about 4 days now and I'm out of ideas...Could someone point me in the right direction?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Problems linking multiple dependent libraries involving XML schema and Cstrings

    It looks like your unnamed SDK is Microsoft MFC-based. Would that be correct?

  3. #3
    Join Date
    Aug 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problems linking multiple dependent libraries involving XML schema and Cstrings

    Hi, thanks for the reply. Yes, as best I can tell the ETrade C++ https://developer.etrade.com/ctnt/de...e-SDKGuides-VC appears to be MFC-based

    initial build after adding all the libraries produced:
    C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

    which prompted me to add the DEFINES += _AFXDLL
    Last edited by aknight3; 23rd August 2015 at 22:14. Reason: additional info

Similar Threads

  1. Linking to GLU libraries
    By beginQT in forum Newbie
    Replies: 0
    Last Post: 26th October 2011, 11:08
  2. Linking to libraries
    By Maluko_Da_Tola in forum Newbie
    Replies: 3
    Last Post: 17th October 2010, 12:19
  3. Problems with "schema" example...
    By Cyrano in forum Qt Programming
    Replies: 0
    Last Post: 22nd February 2010, 14:45
  4. QXmlSchema, XSD Schema validation problems
    By UVV in forum Qt Programming
    Replies: 0
    Last Post: 2nd February 2010, 11:44
  5. linking libraries
    By JustaStudent in forum Newbie
    Replies: 29
    Last Post: 2nd May 2006, 08:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.