Error: "warning C4005: 'SWIGTEMPLATEDISAMBIGUATOR': macro redefinition" - visual-studio

I'm trying to compile a SWIG project, and it keeps on giving errors like this:
swig_wrap.cpp(55): warning C4005: 'SWIGTEMPLATEDISAMBIGUATOR': macro
redefinition
And errors like this:
fatal error C1010: unexpected end of file while looking for precompiled
header. Did you forget to add '#include "stdafx.h"' to your source?
Compiler
Visual Studio 2015+Update 3.
SWIG v3.0.12

Add the following to your .i file:
%begin %{
#include "stdafx.h"
%}
This section injects code into the generated wrapper at the top of the file and you won't need to disable pre-compiled headers.

In Visual Studio, right click on the swig-generated .cpp wrapper file, and select "Not Using Precompiled Headers".
In my case, the wrapper file that swig auto-generated was swig_wrap.cpp.
You can leave precompiled headers on for the entire project.
For more info, see nabble.com and Fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
Appendix A: SWIG could be fixed to avoid this!
Another way to fix this is to manually add the line "stdafx.h" to the start of this file, but unfortunately, every time swig is run it will remove this fix! There is a way to fix this, but its not at all obvious (see the other answer).

Related

How do I correctly set up WXWidgets on Ubuntu? My editor tells me the header files are incorrect

I wanted to try out the WXWidgets Hello World example (https://docs.wxwidgets.org/latest/overview_helloworld.html) so I followed the recommended practice on the Downloads page and installed the WXGTK package for my distribution, Ubuntu, which appears to be libwxgtk3.0-gtk3-dev. After doing this, and copying the example code, g++ (installed from build-essentials) throws an error when I attempt to compile the program:
wxtest.cpp:4:10: fatal error: wx/wxprec.h: No such file or directory
4 | #include <wx/wxprec.h>
| ^~~~~~~~~~~~~
compilation terminated.
My editor (VSCode) also shows me an error: cannot open source file "wx/wxprec.h".
This appears to be related to the fact that the WXWidgets header files are installed to the folder wx-3.0/wx instead of wx, but after changing #include <wx/wxprec.h> to #include <wx-3.0/wx/wxprec.h> I still get an error:
In file included from wxtest.cpp:4:
/usr/include/wx-3.0/wx/wxprec.h:12:10: fatal error: wx/defs.h: No such file or directory
12 | #include "wx/defs.h"
| ^~~~~~~~~~~
compilation terminated.
What am I doing wrong? How can these files be put in the right place?
See the building your project section of the docs.

The .asm file below compiles and builds as expected but the linker emits a warning. I'd like to know why the warning

As can be seen in the picture below, the Output window for the Build shows the following linker warning:
warning LNK4258: directive '/ENTRY:main#0' not compatible with switch '/ENTRY:main'; ignored
What exactly is being warned here?

cmake generated visual studio solution failed to build

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?
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!

fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?

it says: fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source? But if I add '#include "StdAfx.h"' as it required, more error will appear. What should I do please?
This is a Visual Studio issue with precompiled headers. If you compile a file and request precompiled headers you have to include this stdafx file. If you disable use of precompiled headers for either the project or for the file then you no longer have to include this header. Look though the project settings for the right checkbox or check the /Y options you are passing. /Y- can disable precompiled header usage.

troubles with included files in Xcode

I have a problem with include files in Xcode, while I am compiling a gstreamer project.
The header search path contains :
"/Library/Frameworks/GStreamer.framework/Versions/0.10/Headers"
When I am including a header file :
#include <gst/gst.h> the CMD+click function to follow the link answer me " SYMBOL NOT FOUND ".
Moreover, I have compilation problems, I am sure the reason is here.
Thanks

Resources