0

I am currently working on a project on windows 10 and was asked to use some c++ code for it. The code was written with plattform independence in mind. So I used the given cmake files to build a visual studio solution (VS 2015 Update 3). But when I try to build the solution it gives me over 900 errors and warnings.

The same project was successfully build on a mac using cmake and g++. The project itself uses a Qt gui and some additional libaries like boost.

To understand the errors you have to know, that the solution consists of 5 projects: ALL_BUILD, iModControll, iModDaemon, iModView and ZERO_CHECK

There are a lot errors like:

missing type specifier - int assumed. Note: C++ does not support default-int

inconsistent dll binding

declaration not found

unexpected token before ;

and so on... You can see the full list here

I am very new to cmake and not an VS expert, so please help me to understand what went wrong here. Again: the code compiled perfectly under OSX.

EDIT:

I used mingw, as @MaxGo suggested. The errors and warnings were reduced after that. Here is what I have now:

warning: void DC_TermFunc()' redeclared without dllimport attribute after being referenced with dll linkage

  void DC_TermFunc(void)
  {
  if(controller)
   {
    qDebug() << "Terminating iModSkynet";
    runthread->terminate();
    delete runthread; // This will delete the controller too
   }
  }

error: function 'void DC_SendData(char, char*, int)' definition is marked dllimport

  IMODCONTROLLSHARED_EXPORT void DC_SendData(char oc, char* data, int    length)
  {
    QByteArray qdata = QByteArray(data, length);
    controller->sendBlenderCommunication(oc, qdata);
  }

The other errors are similar. My question is: Are there any known issues when porting c++ source code to windows, why does it not show as many errors as in VS and what can I do to solve these errors?

Carlz
  • 1
  • 2
  • 2
    The question is almost useless without the code itself. Before providing the code, note that it should be some sort of [mcve] - Stack Overflow is for specific problems, not for "help me to debug some big code". However, it is better to google each specific error, and take appropriate action: either to correct the code, or to change compiler options. – Tsyvarev Apr 15 '17 at 20:22
  • if your project was never built with Visual Studio msvc compiler before, most of all it will not work "from the box". you can try to build the project using MinGW on Windows, this might work better. – Max Go Apr 15 '17 at 20:23
  • @MaxGo Thank you very much for your help! I edited my post to make the problem more clear. – Carlz Apr 16 '17 at 14:25
  • You should be able to ignore warnings, but need to deal with errors. Regarding the error you mentioned, it seems that during compilation IMODCONTROLLSHARED_EXPORT macros of your project is not defined as __declspec(dllexport). You should find how to make it defined in this way, if you are building shared library. For some kind of sample, you can check here http://stackoverflow.com/questions/20644151/error-function-definition-is-marked-dllimport – Max Go Apr 16 '17 at 19:33

1 Answers1

0

CMake Configuration- Boost- Visual Studio - C++

Step 1: Download CMake installation file, install and save it in local disk

Step 2: Create 2 Folders in local disk a) Raw File b)Solution File

Step 3: Raw File folder- Create a Main.cpp file and paste your raw c++ code it it and save. Now in the same folder create a txt file named CMakeLists and paste the following code in it and save.

cmake_minimum_required(VERSION 3.7)
project (cmboosttest)
#find_package(Boost REQUIRED)
#include_directories(${Boost_INCLUDE_DIR})
add_executable(boosttest ${PROJECT_SOURCE_DIR}/Main.cpp)

Step 4: Open CMake choose Raw File folder in browse source and Solution File Folder in browse build.

Step 5: Click Configure. Once it succeeds, click Generate.

Step 6: When you open the Solution File folder, you can see the built solution file. Click on it and your program will open in Visual Studio. Now, build your program in VS.

Hope this helps!

DivyaMaheswaran
  • 886
  • 1
  • 12
  • 16