Compiler error when running Simulink models from Visual Studio - c++

I have compiled all subsystems of a big, complex, Simulink model into a series of dlls. All of them are working in Visual Studio except one. The one that is not working is the only one that requires the simstruc.h header file, and I get about 120 error messages when I try to compile them. Most of them are in simstruc.h, but also in subsequent includes, like sfcn_bridge.h for example. All of them look the same way:
error C2143: syntax error : missing ';' before '*' c:\matlabr2011b_x86\rtw\c\src\sfcn_bridge.h (37)
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\matlabr2011b_x86\rtw\c\src\sfcn_bridge.h (37)
.
error C2143: syntax error : missing ';' before '*' c:\matlabr2011b_x86\simulink\include\simstruc.h (2135)
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\matlabr2011b_x86\simulink\include\simstruc.h (2135)
The code in the line in above example looks like this:
sfcn_bridge.h (37):
SS_SimMode *simModePtr;
simstruc.h (2135):
SparseHeader* slvrJacobianMatrix;
I have been able to compile programs that include simstruc.h before, but suddenly it's not working. Can anyone point me in the right direction?

Check if any of your class declaration missing ";" at the end.
class AAA
{
}; <--- this one
Edit:
Try these tips as well.
Rebuild the project
Right Click on each cpp file and click "Compile" to identify infected files.
Check include paths. specially sub folders in simulink include directory.
Go to the declaration of SparseHeader struct and check if it get skipped by any #ifdefs or any preprocessor definitions.
If your code base is small, comment out half of it until you get a compilable code. This is not easy however.

Related

VLC-Qt building from source on Windows error

The point is that I try to build vlc-qt binding from source. I do the following:
Get libvlc-qt_0.10.0_win32_msvc2013.7z sources
Open my Qt5 Creator (from MVSC2013 version)
Open /src/CMakeLists.txt with it
Run CMake
Press build
Should work, but instead I get the following:
C:\Program Files (x86)\VideoLAN\VLC\sdk\include\vlc\plugins\vlc_threads.h:403: ошибка: C3861: 'poll': identifier not found
C:\Program Files (x86)\VideoLAN\VLC\sdk\include\vlc\plugins\vlc_configuration.h:103: ошибка: C2146: syntax error : missing ';' before identifier 'config_GetIntChoices'
C:\Program Files (x86)\VideoLAN\VLC\sdk\include\vlc\plugins\vlc_configuration.h:103: ошибка: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\VideoLAN\VLC\sdk\include\vlc\plugins\vlc_configuration.h:104: ошибка: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\VideoLAN\VLC\sdk\include\vlc\plugins\vlc_configuration.h:105: ошибка: C2146: syntax error : missing ';' before identifier 'config_GetPszChoices'
C:\Program Files (x86)\VideoLAN\VLC\sdk\include\vlc\plugins\vlc_configuration.h:105: ошибка: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\VideoLAN\VLC\sdk\include\vlc\plugins\vlc_configuration.h:106: ошибка: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
The surprises are that this project searches for some files in the current VLC player installation (Program Files is likely not the best place to get the dependecies), also that nothing's told about this behavior on the repository page, at first sight at at least.
Currently I'm trying to remove/reinstall player, run CMake with some keys etc. By the way, downloading CMake with gui never helped.
Could anyone, please, point me at the mistake in building. Thanks in advance.
UPD:
Thanks, krnekit, it helped to get the key! Ah, it occured to be even more complicated (msvc 2013 update 4 used).
Briefly:
It's pretty hard to build the binding from source via Qt Creator + nmake
Telling CMake with CMAKE_PREFIX_PATH variable, where qt required libraries are helps a lot
The problem of searching vlc player headers in sdk is solved similarly after some of the Cmake configuring
When I started building my sample with the vlc-qt sources included, instead of using the shared dll, I understood that /src/windows contains headers (poll.h and other) are requied to prevent the errors. Don't really know, why it didn't work with Cmake doing it instaed of me
This is a problem with vlc, not with vlc-qt. Your program should be compiled with at least VS 2013 Update 2 (or maybe even more recent).
Alternatively, the quick and dirty solution is to modify vlc includes, see this bugreport for details. You also should provide poll.h include file.

How to fix compile errors when including emscripten headers?

I'm trying to use emscripten Embind to bind C++ functions to JavaScript. Unfortunately I already get compile errors when including the specific header file with #include <emscripten/bind.h>.
I checked my emscripten environment and set an additonal Include Directory in VS2013 to the absolute path of the installation folder (also tried $(EMSCRIPTEN); and adapted the inlcude statement).
When compiling my project, I get 20+ compile errors:
17>d:\program files\emscripten\emscripten\1.25.0\system\include\emscripten\wire.h(24): error C2144: syntax error : 'bool' should be preceded by ';'
17>d:\program files\emscripten\emscripten\1.25.0\system\include\emscripten\wire.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
17>d:\program files\emscripten\emscripten\1.25.0\system\include\emscripten\wire.h(39): error C2146: syntax error : missing ';' before identifier 'TYPEID'
17> d:\program files\emscripten\emscripten\1.25.0\system\include\emscripten\wire.h(42) : see reference to class template instantiation 'emscripten::internal::CanonicalizedID<T>' being compiled
17>d:\program files\emscripten\emscripten\1.25.0\system\include\emscripten\wire.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
17>d:\program files\emscripten\emscripten\1.25.0\system\include\emscripten\wire.h(54): error C2146: syntax error : missing ';' before identifier 'TYPEID'
...
I tried emscripten 1.22.0 and 1.25.0 and verified my emscripten environment following those instructions. What am I missing?
As far as I know, of the MS Visual Studio editions, only VS2010 is supported in Emscripten.
http://kripken.github.io/emscripten-site/docs/getting_started/getting_started_with_emscripten_and_vs2010.html#getting-started-emscripten-from-visual-studio

Trying to embed a web browser into a c++ Win32 project. Error about MyIOleInPlaceFrameTable

Can someone help me out. My goal is to put a child web browser window into my C++ project. I got a sample code from here:
http://www.codeproject.com/KB/COM/cwebpage.aspx
And then tried to compile it with VS 2008. Their sample project compiled and worked just fine.
Then using the same VS 2008 I started putting the code into my project, that is again, a native Win32 GUI application written in C++. I added almost all the code from "Simple\Simple.c" file one-to-one into my C++ project, but when I try to compile it I get a million error messages, starting with this one:
embed_htm_test.cpp(91) error C2146: syntax error : missing ';' before identifier 'MyIOleInPlaceFrameTable'
embed_htm_test.cpp(91) error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
embed_htm_test.cpp(91) error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
then about 20 error codes below:
embed_htm_test.cpp(158) : error C2146: syntax error : missing ';' before identifier 'MyIOleClientSiteTable'
embed_htm_test.cpp(158) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
embed_htm_test.cpp(158) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
and so on.
The first error would fall on this line:
IOleInPlaceFrameVtbl MyIOleInPlaceFrameTable = {Frame_QueryInterface,
Frame_AddRef,
Frame_Release,
Frame_GetWindow,
Frame_ContextSensitiveHelp,
Frame_GetBorder,
Frame_RequestBorderSpace,
Frame_SetBorderSpace,
Frame_SetActiveObject,
Frame_InsertMenus,
Frame_SetMenu,
Frame_RemoveMenus,
Frame_SetStatusText,
Frame_EnableModeless,
Frame_TranslateAccelerator};
and the second one on this line:
IOleClientSiteVtbl MyIOleClientSiteTable = {Site_QueryInterface,
Site_AddRef,
Site_Release,
Site_SaveObject,
Site_GetMoniker,
Site_GetContainer,
Site_ShowObject,
Site_OnShowWindow,
Site_RequestNewObjectLayout};
I also included all the includes from the original project:
#include <windows.h>
#include <exdisp.h> // Defines of stuff like IWebBrowser2. This is an include file with Visual C 6 and above
#include <mshtml.h> // Defines of stuff like IHTMLDocument2. This is an include file with Visual C 6 and above
#include <mshtmhst.h> // Defines of stuff like IDocHostUIHandler. This is an include file with Visual C 6 and above
#include <crtdbg.h> // for _ASSERT()
And for the best of me, I can't figure out where IOleInPlaceFrameVtbl and IOleClientSiteVtbl could be defined in. Any idea guys?
By default in C++ it will define the C++ OLE interfaces. To get the C style interfaces, prior to the includes add
#define CINTERFACES
Check if the file extension is .cpp. Change to .c and rebuild. For me it worked fine.

How to SWIG in VS2010?

Hey Everybody,
I'm trying to SWIG a multi file project that I made in VS2010 (c++) to python. I've managed to link the Python26.lib file, and have SWIG generating a wrapper .cpp file for my main .cpp file. I've set my code to build a .dll with the extension .pyd.
This is the .i file I have currently:
%module HiveGPS
%{
#include "ou_thread.h"
#include "HiveGPS.h"
%}
%include ou_thread.h
%include HiveGPS.h
And I've mangaed to get a .py and .pyc file. Now, from my understanding in order to run my .py file, I need to link it to my .pyd file, but when I try to use VS2010 to build my project with the settings I listed above, it complains about a Thread class I'm using:
1>------ Build started: Project: HiveGPS, Configuration: Release Win32 ------
1>Build started 5/11/2011 1:41:30 PM.
1>InitializeBuildStatus:
1> Touching "Release\HiveGPS.unsuccessfulbuild".
1>ClCompile:
1> HiveGPS_wrap.cpp
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(57): error C2146: syntax error : missing ';' before identifier 'm_strName'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(64): error C2146: syntax error : missing ';' before identifier 'getName'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(64): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(64): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(64): warning C4183: 'getName': missing return type; assumed to be a member function returning 'int'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(98): error C2146: syntax error : missing ';' before identifier 'm_strName'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(98): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(98): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(104): error C2146: syntax error : missing ';' before identifier 'getName'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(104): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(104): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(104): warning C4183: 'getName': missing return type; assumed to be a member function returning 'int'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(115): error C2146: syntax error : missing ';' before identifier 'msg'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(118): error C2146: syntax error : missing ';' before identifier 'getMessage'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(118): warning C4183: 'getMessage': missing return type; assumed to be a member function returning 'int'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(51): error C2011: 'openutils::Thread' : 'class' type redefinition
1> c:\users\*\desktop\hivegps\hivegps\ou_thread.h(51) : see declaration of 'openutils::Thread'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(93): error C2011: 'openutils::Mutex' : 'class' type redefinition
1> c:\users\*\desktop\hivegps\hivegps\ou_thread.h(93) : see declaration of 'openutils::Mutex'
1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(113): error C2011: 'openutils::ThreadException' : 'class' type redefinition
1> c:\users\*\desktop\hivegps\hivegps\ou_thread.h(113) : see declaration of 'openutils::ThreadException'
1>c:\users\*\desktop\hivegps\hivegps\HiveGPS.h(29): error C2504: 'openutils::Thread' : base class undefined
1>c:\users\*\desktop\hivegps\hivegps\HiveGPS.h(53): error C2079: 'HiveGPS::readWriteMutex' uses undefined class 'openutils::Mutex'
1>HiveGPS_wrap.cpp(3086): error C2027: use of undefined type 'openutils::Thread'
1> c:\users\*\desktop\hivegps\hivegps\ou_thread.h(51) : see declaration of 'openutils::Thread'
1>HiveGPS_wrap.cpp(3086): fatal error C1903: unable to recover from previous error(s); stopping compilation
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.10
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
All of these errors (minus the last one) are basically saying that the String class is implemented somehow, is it conflicting with Python's definition of the String class? The last error is complaining about the Thread class, could that be the same problem?
All of that said:
Can somebody tell me what I'm doing wrong, or better yet, point me to a tutorial of how to do this for VS2010 (the SWIG site is for 2008).
And if that can't be done, can I link the .py file I have generated to the .dll file somehow?
Sorry for the long explanation but I'm kinda lost on this one so I decided to explain everything.
Ok, I'm using swig and VS2010 with no problems...
In your case, it looks more like you have problems with linking. Beyond the check of libraries, dont forget to check 32-64 bit libraries you are linking. Try to link all as x86 target as fail-safe. And don't use AnyCpu.
How to use SWIG under VS2010.
lets define you want to obtain mylib.py, so you created some SWIG interface files with mylib.i as "main" file. I assume that you already have a solution with project with your C++ classes there.
(1) First create C++ project for SWIG interface. Use Visual C++->Class library project which should create a C++ DLL stub. I put all .i files there. And set visual studio to highlight .i as .h - it is handy.
(1.1) Add mylib_wrap.cxx file to the project (create empty file while swig hasn't generated one yet)
(2)
a) Press right button over the mylib.i, choose properties.
b) set ItemType as "Custom build tool".
In custom build step window:
c) Command line field should be something like:
echo In order to function correctly, please ensure the following environment variables are
correctly set:
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
C:\swig\swig.exe -c++ -python %(FullPath)
change C:\swig\swig.exe to your path to SWIG
d) In Outputs field:
$(InputName)_wrap.cxx
(3) Go to this project properties:
a) C++ tab -> Additional Include Directories
add $(PYTHON_INCLUDE); ...
c) Linker -> Output File
Path-You-Needed\_mylib.pyd
d) Linker -> Enable Incremental Linking
set as No (/INCREMENTAL:NO)
e) Linker -> Input -> Additional Dependencies
add $(PYTHON_LIB);...
f) C/C++ -> Precompiled Headers:
Switch off precompiled headers, set **Not Using Precompiled Headers* and remove stdafx files after
g) General tab. Just check that these are set:
Configuration type = Dynamic Library (.dll)
Character set = Use Unicode Character Set
Common Language Runtime Support = No Common Language Runtime Support
It compiles.
P.S. And dont forget to set %PYTHON_INCLUDE% and %PYTHON_LIB% variables in your system too.
It seems that some #include is missing in the ou_thread.h.
Further more, the "'class' type redefinition" can indicate that you don't have something like
#ifndef __ou_thread_h__
#define __ou_thread_h__
// your stuff, classes, etc.
#endif
in your ou_thread.h
It's a guessing...

Compiliation errors on boost files

I'm getting a lot of errors compiling code using the boost libraries, mainly when I'm using Spirit namespace. The errors are syntax errors on boost files like:
boost/spirit/home/classic/dynamic/lazy.hpp(33) : error C2143: syntax error : missing ';' before '<'
or
boost/spirit/home/classic/dynamic/lazy.hpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
or
boost/spirit/home/classic/utility/grammar_def.hpp(104)
: error C2039: 'nil_t' : is not a
member of 'boost::phoenix'
I am migrating from Visual Studio 6 to Visual Studio 2008 Express and from one of the oldest versions of boost to the lastest.
I'd like to know what's the problem. I'm thinking the problem can't be in the boost library.
My guess, like Timi Geusch, is an errant #define.
I've never used VS, but if there is an option to see the code after it has been passed through the preprocessor, you might be able to figure out what causing the problem.
The problem was resolved just including phoenix1 the old version of phoenix.