Jump to content
Matthias Jung

Mingw Compile Issue

Recommended Posts

Im setting up SystemC with qmake:

TARGET = systemc

TEMPLATE = lib
CONFIG += staticlib
CONFIG -= qt

QMAKE_CXXFLAGS = -Wall -O3 #-std=c++11
QMAKE_CFLAGS = -Wall -O3

INCLUDEPATH += src/

SOURCES += $$files(src/sysc/communication/*.cpp, true)
SOURCES += $$files(src/sysc/datatypes/bit/*.cpp, true)
SOURCES += $$files(src/sysc/datatypes/fx/*.cpp, true)
SOURCES += $$files(src/sysc/datatypes/int/*.cpp, true)
SOURCES += $$files(src/sysc/datatypes/misc/*.cpp, true)
SOURCES += $$files(src/sysc/kernel/*.cpp, true)
SOURCES += $$files(src/sysc/tracing/*.cpp, true)
SOURCES += $$files(src/sysc/utils/*.cpp, true)

HEADERS += $$files(src/sysc/communication/*.h, true)
HEADERS += $$files(src/sysc/datatypes/bit/*.h, true)
HEADERS += $$files(src/sysc/datatypes/fx/*.h, true)
HEADERS += $$files(src/sysc/datatypes/int/*.h, true)
HEADERS += $$files(src/sysc/datatypes/misc/*.h, true)
HEADERS += $$files(src/sysc/kernel/*.h, true)
HEADERS += $$files(src/sysc/packages/boost/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/bind/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/config/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/config/compiler/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/config/platform/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/config/stdlib/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/detail/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/mpl/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/mpl/aux_/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/mpl/aux_/config/*.hpp, true)
HEADERS += $$files(src/sysc/packages/boost/utility/*.hpp, true)
HEADERS += $$files(src/sysc/tracing/*.h, true)
HEADERS += $$files(src/sysc/utils/*.h, true)
HEADERS += $$files(src/sysc/qt/qt.h, true)

SOURCES += $$files(src/sysc/qt/qt.c, true)

!contains(QMAKE_TARGET.arch, x86_64) {
    message("x86 build")
    SOURCES += $$files(src/sysc/qt/md/i386.s, true)
} else {
    message("x86_64 build")
    SOURCES += $$files(src/sysc/qt/md/iX86_64.s, true)
}

Under Windows I have this compilation issue when I use Mingw as compiler:

..\systemc-2.3.2-qmake\src\sysc\kernel\sc_ver.cpp:166:1: error: specialization of 'sc_core::sc_api_version_2_3_2_cxx201103L<DisableVirtualBind>::sc_api_version_2_3_2_cxx201103L(sc_core::sc_writer_policy) [with const int* DisableVirtualBind = (& sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_)]' after instantiation

)

^

Has somebody an idea whats going on here?

 

I assume that it has something to do with the order of the building?

Share this post


Link to post
Share on other sites

Hello @Matthias Jung,

It seems you are missing some of the compiler definition flags for the build:

-DSC_BUILD ... etc.

You can get the set of compiler flags for the SystemC library from the CMake generator(Only works with Makefile generator).

# Using CMake to create compile_commands.json
# SYSTEMC_SRC: SystemC source directory.
cd $<SYSTEMC_SRC>
# Create a build directory
mkdir build
cd build

# Run CMake configuration for Make file generator.
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..

Note: Also the quick thread library for user space thread support will not work on Windows since it is compatible only on Linux systems.

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

Hi @Matthias Jung,

You should use cmake generator provided from MinGW package manager.

In-case you are using the version from CMake official release then you would need to add the MinGW utilities to the system PATH environment variable.

set MINGW_HOME=<PATH to MINGWROOT>

set PATH=%PATH%:%MINGW_HOME%/bin

# Check if you have make available on the cmd.exe
make --version

# Check if gcc/g++ is available on the cmd.exe
gcc --version
g++ --version

# Configure CMake to use the make file generator on the configuer step in SystemC build directory.

cmake -G "MinGW Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
# or in-case the previous one doesn't work.
cmake -G "MSYS Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..

Note: To find the list of supported generator from CMake you can use this command:

cmake -G --help

Update: Here is the official documentation on the CMake Makefile Generator: https://cmake.org/cmake/help/latest/generator/MinGW Makefiles.html#generator:MinGW Makefiles

Regards,

Ameya Vikram Singh

Edited by AmeyaVS
Added link for the official documentation for CMake

Share this post


Link to post
Share on other sites

If you want to build SystemC inside QtCreator you can use CMake project bundled with systemc 2.3.2 ( Open Project, select CMakeLists.txt) .  There is no need to create a qmake project.

Share this post


Link to post
Share on other sites
15 hours ago, Roman Popov said:

If you want to build SystemC inside QtCreator you can use CMake project bundled with systemc 2.3.2 ( Open Project, select CMakeLists.txt) .  There is no need to create a qmake project.

I tried that before and it was not working. However, now its working thanks for the hint!

Regards

Matthias

Share this post


Link to post
Share on other sites

So I can build sucessfully SystemC with QtCreator under Windows with MinGW that is provided with QtCreator using CMake. So it should now be pretty save that the SystemC compiling process is correct.

However, when I use the SystemC Library withing one of my projects, I have again this error:

C:/<...>/Qt/Tools/mingw530_32/bin/mingw32-make -f Makefile.Release

mingw32-make[1]: Entering directory 'C:/<...>/Programming/SCVP.artifacts/build-tlm_at_1-Desktop_Qt_5_10_0_MinGW_32bit-Release'

g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release\tlm_at_1.exe release/main.o release/memory_manager.o -LC:\Users\jung\Programming\systemc-2.3.2\build-systemc-2.3.2-Desktop_Qt_5_10_0_MinGW_32bit-Default\src -lsystemc

C:\<...>\main.cpp:-1: error: undefined reference to `sc_core::sc_api_version_2_3_2_cxx201103L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx201103L(sc_core::sc_writer_policy)'

This are the Flags used by CMake 

[
{
  "directory": "C:/<...>/Programming/systemc-2.3.2/build-systemc-2.3.2-Desktop_Qt_5_10_0_MinGW_32bit-Default/src",
  "command": "C:\\<...>\\Qt\\Tools\\mingw530_32\\bin\\g++.exe  -DSC_BUILD -DSC_ENABLE_ASSERTIONS -DSC_ENABLE_EARLY_MAXTIME_CREATION -DSC_ENABLE_SIMULATION_PHASE_CALLBACKS_TRACING -DSC_INCLUDE_FX -DWIN32 @CMakeFiles/systemc.dir/includes_CXX.rsp -O3 -DNDEBUG   -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -std=gnu++98 -o CMakeFiles\\systemc.dir\\sysc\\communication\\sc_clock.cpp.obj -c C:\\<...>\\Programming\\systemc-2.3.2\\systemc-2.3.2\\src\\sysc\\communication\\sc_clock.cpp",
  "file": "C:/<...>/Programming/systemc-2.3.2/systemc-2.3.2/src/sysc/communication/sc_clock.cpp"
},
...
]

Here is the qmake project example:

TARGET = tlm_at_1

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

INCLUDEPATH += C:\<...>\Programming\systemc-2.3.2\systemc-2.3.2\src
LIBS += -LC:\<...>\Programming\systemc-2.3.2\build-systemc-2.3.2-Desktop_Qt_5_10_0_MinGW_32bit-Default\src -lsystemc

HEADERS += ../tlm_memory_manager/memory_manager.h
HEADERS += initiator.h
HEADERS += target.h
HEADERS += util.h

SOURCES += main.cpp
SOURCES += ../tlm_memory_manager/memory_manager.cpp

It seams that Systemc was build with -std=gnu++98 also adding this flag to the qt-project does not help to solve the issue.

Share this post


Link to post
Share on other sites

Hello @Matthias Jung,

Can you post the version of the g++ compiler?

Also using the bash shell of the MinGW environment post the output of the following command:

# Note provide the full path to SystemC static library
nm -C <full_path_to_libsystemc.a> | grep sc_api_version

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites
C:\<...>\main.cpp:-1: error: undefined reference to `sc_core::sc_api_version_2_3_2_cxx201103L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx201103L(sc_core::sc_writer_policy)'

This error suggests that you are building your application with cxx201103L = C++11.  But SystemC library was build with C++98.

So you either have to rebuild SystemC library with C++11, or use C++98 for your application.

Here is an example how to build SystemC and Applications using CMake (with option to enable C++11):

https://stackoverflow.com/a/46880679/1503413

If you are using CMake, you can configure your application to use same C++ standard you were using for library build automatically:

find_package(SystemCLanguage CONFIG REQUIRED)
set (CMAKE_CXX_STANDARD ${SystemC_CXX_STANDARD})

Btw, g++ 5.3 you are using supports C++14, so you can use it instead of C++11. Just pass -DCMAKE_CXX_STANDARD=14 when generating Makefile using CMake.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×