0

I am trying to create a project assosiated with the SimConnect SDK.

I am new to QT, and in Visual Studio, I just had a SimConnect.h file, a .lib file, and a .dll file, and I managed to make it work. Now I am trying to create a C++ widget project, using the same SDK, but in QT.

I put the header file in my QT project's folder, where the other default code and header files are located, and then I went to the project and added them as existing files, as I read in Google. I'm having problems with the actual library.

I've been searching Google for a guide on how to add a library file to the project, I did some things I saw on the internet, like the LIBS line for example, but I probably did it wrong, even though it looked very simple. I am not sure where to drop my dll/library files in the project directory, maybe the problem is I always put them in the wrong spot.

The furthest I got to, was an error message saying "Unresolved external symbol", and a red writing saying ".obj file not found" on every function I tried to use from the SimConnect functions, which probably means QT couldn't find my library/dll file.

I also tried to add the libraries from the "Add library" option in the project, but that didn't work too.

EDIT: it also warns "warning: LNK4272: library machine type 'X86' conflicts with target machine type 'x64'" maybe it has to do something with it.

halfer
  • 19,824
  • 17
  • 99
  • 186
Nir
  • 27
  • 1
  • 5
  • Possible duplicate of [Adding external library into Qt Creator project](http://stackoverflow.com/questions/718447/adding-external-library-into-qt-creator-project) – m7913d Apr 22 '17 at 11:33
  • 1
    You just need the `LIBS +=` statement as done in the mentioned thread. Be sure to change `/path/to` into the path of the linked library. – m7913d Apr 22 '17 at 11:36
  • @m7913d This is exacly what I did, i added the library through the "Add library option", so the line was created automatically. As I said, ive been looking googling all day long, and it still shows me this error, like QT doesnt find my library or something – Nir Apr 22 '17 at 11:49
  • Strange, it should work. You can also try: `LIBS += absolute_path_to_lib.lib`. – m7913d Apr 22 '17 at 11:57
  • @m7913d Tried it too aswell, I edited my post, added the warning it gives me, "warning: LNK4272: library machine type 'X86' conflicts with target machine type 'x64'" Perhaps has something to do with it? – Nir Apr 22 '17 at 12:05
  • That explains a lot. The library seems to be compiled for 32bit and now you try to link it with your 64bit program. – m7913d Apr 22 '17 at 12:07
  • @m7913d Is there any way to change my program to 32bit then maybe? – Nir Apr 22 '17 at 12:08
  • You should change your kit (or add a new one). In Tools > Options > Build & Run > Kits (or Projects > Manage Kits...), select your kit and specify a 32bit Qt version & compiler. Probably you also have to download a 32bit Qt version or build one yourself. – m7913d Apr 22 '17 at 14:17
  • @m7913d Thank you for helping me, I will try it out and let you know! – Nir Apr 22 '17 at 14:27
  • It may be useful for other people with the same question that you clean up your question to include only the essential part of your problem and that you formulate a solution yourself. – m7913d Apr 22 '17 at 14:29
  • @m7913d You are my hero friend, thanks! I will change my question to the solution. – Nir Apr 22 '17 at 16:39

1 Answers1

0

(Posted on behalf of the OP).

Solved! My problem was my machine was set to 64bit, while the library was set to 32bit, so I downloaded the 32bit kit, and ran the project through that, and it worked!

halfer
  • 19,824
  • 17
  • 99
  • 186