S-Function with c++. Build error - c++

I'm a newbie in MATLAB. I am trying to build my modell with an example for S-Function from the matlab help. This is the sfun_counter_cpp.cpp. The source code is available in "matlabroot/simulink/src/sfun_counter_cpp.cpp" or on http://www-rohan.sdsu.edu/doc/matlab/toolbox/simulink/sfg/sfun_c++2.html.
First I build C++ S-function with the "mex" command as described here:
http://www.mathworks.de/de/help/simulink/sfg/building-c-s-functions.html.
The build is successful and the sfun_counter_cpp.mexw32 is created. After that I create an S-Function block that provides access to sfun_counter_cpp from my block diagram, click "Incremental build" and get an error message "OPUS MAKE: Don't know how to make 'sfun_counter_cpp.cppm50'. Stop."
*** Found User-Code File TestModell_usr.c from 05-Jul-2013 15:38:59
*** Found User Makefile TestModell_usr.mk from 05-Jul-2013 15:38:59
*** Optional User Variable Description File TestModell_usr.trc not available
.
### Processing Template Makefile: C:\dSPACE\matlab\rti1005\m\rti1005.tmf
### TestModell.mk which is generated from C:\dSPACE\matlab\rti1005\m\rti1005.tmf is up to date
### Building TestModell: dsmake -f TestModell.mk GENERATE_REPORT=0 EXTMODE_STATIC_ALLOC=0 TMW_EXTMODE_TESTING=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 EXTMODE_TRANSPORT=0
BUILDING APPLICATION "TestModell" (Multiple Timer Task Mode)
WORK DIRECTORY "c:\MyTest"
BUILD DIRECTORY "c:\MyTest\TestModell_rti1005"
TARGET COMPILER "C:\PPCTools37"
COMPILING "TestModell.c"
COMPILING "TestModell_data.c"
COMPILING "TestModell_trc_ptr.c"
COMPILING "rtGetInf.c"
COMPILING "rtGetNaN.c"
COMPILING "C:\PROGRA~2\MATLAB~1\rtw\c\src\rt_matrx.c"
COMPILING "rt_nonfinite.c"
COMPILING "C:\dSPACE\MATLAB\RTI1005\C\rt_printf.c"
COMPILING "C:\dSPACE\MATLAB\RTI1005\C\rti_sim_engine.c"
OPUS MAKE: Don't know how to make 'sfun_counter_cpp.cppm50'. Stop.
----------------------------------------------------------------------
*** Errors occurred during make process.
*** Inspect MATLAB Command Window for details.
*** Aborting RTI build procedure for model TestModell.
----------------------------------------------------------------------
*** Stopped RTI build procedure for model: TestModell.
----------------------------------------------------------------------

The problem is solved. I set
USER_BUILD_CPP_APPL = ON
and
USER_SRCS =
USER_SRCS = sfun_counter_cpp.cpp
produces an error
< lnkppc > (E) #A0307-D Symbol: sfun_counter_cpp in file: sfun_counter_cpp.cppm50 already defined in file: sfun_counter_cpp.cppm50

Related

LimeReport compilation: Error 127. What causes this?

I am trying to compile LimeReport in Windows 10 using Qt 5.5.9 and Qt Creator 4.11.0. I get the following compilation output and the compilation stops.
/usr/bin/sh: I:\Programs\Qt\Qt5.9.9\5.9.9\mingw53_32\bin\lupdate.exe: command not found
Makefile.Debug:762: recipe for target 'ts' failed
mingw32-make[2]: *** [ts] Error 127
mingw32-make[2]: *** Waiting for unfinished jobs....
mingw32-make[2]: Leaving directory 'E:/Software/C-CPP Windows GUI Programming/Qt/Plugins + Libs/LimeReport/build-limereport-Desktop_Qt_5_9_9_MinGW_32bit-Debug/limereport'
Makefile:36: recipe for target 'debug' failed
mingw32-make[1]: Leaving directory 'E:/Software/C-CPP Windows GUI Programming/Qt/Plugins + Libs/LimeReport/build-limereport-Desktop_Qt_5_9_9_MinGW_32bit-Debug/limereport'
mingw32-make[1]: *** [debug] Error 2
Makefile:89: recipe for target 'sub-limereport-make_first-ordered' failed
mingw32-make: *** [sub-limereport-make_first-ordered] Error 2
11:20:35: The process "I:\Programs\Qt\Qt5.9.9\Tools\mingw530_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project limereport (kit: Desktop Qt 5.9.9 MinGW 32bit)
When executing step "Make"
lupdate.exe is very much present inside the directory "I:\Programs\Qt\Qt5.9.9\5.9.9\mingw53_32\bin". The directory is part of PATH variable, and typing "lupdate" in cmd works.
Please tell me what is the problem and if I am doing anything wrong.
Note: I downloaded the source code from the official GitHub page and the source code compiles correctly in Linux. The Qt installation inside my Windows compiles all other programs correctly without any problem.
You are using a version of make that invokes a POSIX shell (/bin/sh), not the Windows cmd.exe shell.
In POSIX, backslashes are always escape characters and directories are separated by forward slashes (/) not backslashes.
Somewhere in your makefile you have set a variable to the path I:\Programs\Qt\Qt5.9.9\5.9.9\mingw53_32\bin\lupdate.exe or some part of that: replace the backslashes with forward slashes.
In general, in makefiles you should always use forward slashes as directory separators.
Okay, I used to following workaround to fix this problem:
I could not find any line in make file or pro file that had a mention of I:\Programs\Qt\Qt5.9.9\5.9.9\mingw53_32\bin\lupdate.exe. So, instead inside the limereport/limereport/limereport.pro file, I disabled the ts.commands = $$LUPDATE \"$$PWD\" -noobsolete -ts $$TRANSLATIONS line and qm.commands += $$LRELEASE -removeidentical $$tsfile -qm $$qmfile $$escape_expand(\\n\\t) line and it compiled correctly. I did not want any other-language translations, so I don't care about disabling the above line. This is not a permanent fix but definitely a workaround.

Error using Cygwin: "collect2: fatal error: ld terminated with signal 11 [Segmentation fault]"

I'm trying to use cygwin to download openslide (building natively on Windows) on a Windows 10 x64 system. I ran into an error earlier relating to chk_fail and set the line in the build file with -D_FORTIFY_SOURCE to 0 instead of the default (2). You can probably tell by now I don't really know what I'm doing. But I got a new error below relating to a memory error from what I've read. I tried deleting the whole package folder including the makefiles and object files, then clone from Github again and rebuild, but it didn't work. Can anyone give me pointers about what's happening here and how to fix it? It would be much appreciated.
Scanning dependencies of target ziptool
[ 90%] Building C object src/CMakeFiles/ziptool.dir/ziptool.c.obj
[ 90%] Linking C executable ziptool.exe
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
make[2]: *** [src/CMakeFiles/ziptool.dir/build.make:109: src/ziptool.exe] Error 1
make[2]: *** Deleting file 'src/ziptool.exe'
make[1]: *** [CMakeFiles/Makefile2:442: src/CMakeFiles/ziptool.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
Failed: make $parallel (line 417)
I solved this problem. Firstly, don't even bother to build this package using Cygwin. It won't work because of dependency issues and there is no record for version control in the package README.
For anyone else who has this problem like I did, you can download the latest versions of the code here: https://github.com/openslide/openslide-winbuild/releases and pick the latest one.
I first pip installed openslide-python. Then I moved openslide-win64-20171122 (from Github) into anaconda3/site-packages (not necessary, but nice), and then from anaconda3/site-packages/openslide I opened lowlevel.py.
In lowlevel.py, you need to add the following lines:
(in the beginning after importing libraries)
os.environ['PATH'] = "path/to/openslide-win64-20171122/bin" + ";" + os.environ['PATH']
You can also change this line:
if platform.system() == 'Windows':
_lib = cdll.LoadLibrary('libopenslide-0.dll')
to this:
if platform.system() == 'Windows':
_lib = cdll.LoadLibrary(util.find_library("libopenslide-0.dll"))
so that it searches for the libopenslide-0.dll file. Then don't forget to add from ctypes import util at the beginning.

How to correct path to overcome Error 127?

I'm trying to run a c++ file which requires an mkl library. I installed that library in a folder on home. But I'm getting following error. I searched that this error is due to incorrect path assign. How can I correct that path?
`/public/intel/bin/icpc -g -I/public/intel/mkl/include -c main.cc
make: /public/intel/bin/icpc: Command not found
[main.o] Error 127
makefile:6: recipe for target 'main.o' failed
make: *** [main.o] Error 127`
Jerry,
It looks like you are using Linux or UNIX. Also it looks like you are trying to use ICC (the Intel compiler) with MKL. If you are using ICC, the Linux compile command is "icc", the Windows compile command is "icl".
Beyond that, you need to source the ??vars.sh files if you have not set the environment variables manually. For example, if you installed Parallel Studio, you would set up compiler environment variables as explained here: https://software.intel.com/en-us/articles/setting-up-the-build-environment-for-using-intel-c-or-fortran-compilers; and you would set up MKL environment variables as explained here: https://software.intel.com/en-us/mkl-linux-developer-guide-scripts-to-set-environment-variables.
Let me know if this helps.

Error when build Ogre on Linux: narrowing conversion

I am trying to get Ogre on Linux. I downloaded the source files and uncompressed them. Then I created the build folder then I ran "cmake ..". After that completed, I ran "make -j4" (I do have 4 cores and I have also tried just make). I get to 49% and it stops every time. I have downloaded the cmake gui and ran configure and checked all the boxes. I hit configure again and then generate. I tried running "make" again.
Downloads/ogre_src_v1-8-1/RenderSystems/GL/src/atifs/src/ps_‌​1_4.cpp:689:1: error: narrowing conversion of ‘-35051’ from ‘int’ to ‘uint {aka unsigned int}’ inside { } [-Wnarrowing] };
That is the error that pops up several times except they refer to a different line of the code in ps_1_4.cpp and the number ‘-35051’ is different.
Also, There are several warnings for casting the const GLboolean* to GLboolean* throughout the build but this is the message that I have at the end:
RenderSystems/GL/CMakeFiles/RenderSystem_GL.dir/build.make:542: recipe for target 'RenderSystems/GL/CMakeFiles/RenderSystem_GL.dir/__/__/RenderSystem_GL/compile_RenderSystem_GL_0.cpp.o' failed
make[2]: *** [RenderSystems/GL/CMakeFiles/RenderSystem_GL.dir/__/__/RenderSystem_GL/compile_RenderSystem_GL_0.cpp.o] Error 1
CMakeFiles/Makefile2:1057: recipe for target 'RenderSystems/GL/CMakeFiles/RenderSystem_GL.dir/all' failed
make[1]: *** [RenderSystems/GL/CMakeFiles/RenderSystem_GL.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
Also every time that I have tried a new way I delete the build folder and start all over. Each time it appears to end with this message. I am still relatively new to Linux and CMake, so can you explain what is going on and how you came to this conclusion?
Note: I have found one forum that talks about this but I don't know where the build function is or how to change the CXX_FLAG.
Referenced post suggests that Ogre can be successfully built using gnu++98 standard (which is actually a c++98 plus GNU extensions).
The standard is set via compiler flags, in case of cmake flags may be passed as:
cmake -DCMAKE_CXX_FLAGS="--std=gnu++98" ..

opencv_perf_stitching_Release.gch not generated by cmakefiles

I am trying to configure openCV with codeblocks but It got stuck during mingw32-make step, giving me this error:
[ 94%] Generating
perf_precomp.hpp.gch/opencv_perf_stitching_Release.gch
C:/openCV/opencv/build/x86/mingw/modules/stitching/perf_precomp.hpp:1:0:
fatal error: can't creat e precompiled header
C:/opeCV/opencv/build/x86/mingw/modules/stitching/perf_precomp.hpp.gch/opencv_perf_stitching_Release.gch:
No such file or directory #ifdef __GNUC__ ^ compilation terminated.
modules\stitching\CMakeFiles\pch_Generate_opencv_perf_stitching.dir\build.make:61:
recipe for tar get
'modules/stitching/perf_precomp.hpp.gch/opencv_perf_stitching_Release.gch'
failed mingw32-make[2]: ***
[modules/stitching/perf_precomp.hpp.gch/opencv_perf_stitching_Release.gch]
E rror 1 CMakeFiles\Makefile2:6569: recipe for target
'modules/stitching/CMakeFiles/pch_Generate_opencv_pe
rf_stitching.dir/all' failed mingw32-make[1]: ***
[modules/stitching/CMakeFiles/pch_Generate_opencv_perf_stitching.dir/all]
Er ror 2 Makefile:159: recipe for target 'all' failed mingw32-make:
*** [all] Error 2
I am unable to resolve it!
I am using windows 7 32bit
I met the similar problem that may be caused by cmd input limitation.
The cmd input limitation in win7 is about 8000 characters and in most case that is enough.
However in opencv build,one built component (opencv_perf_stitching_Release) might break this limition due to a long executed command.Because of different folder length for different users,the cutting point in executed command is located at unfixed position.Their error messages are also totally distinctive.In my example,I got a message unrecognized command line option '-sse' but i doubt we met the same problem.
The simplest solutiuon is to reduce your building folder level.In your case,you can change your install path from C:/opeCV/opencv/ to C:/opencv/ and try again.