I have trouble making Clang work with MinGW on Windows.
I have MinGW-W64-builds-4.3.3 installed (GCC 7.2.0) as well as the newest Clang/LLVM (by installer on the website).
I am compiling with:
-target x86_64-pc-windows-gnu
option and Clang finds all the headers. Unfortunately there is an error from the linker when I am using OpenMP. It looks like this:
: undefined reference to `__imp___kmpc_fork_call'
\libgomp.a(team.o):(.text+0x19): undefined reference to `pthread_mutex_destroy'
...
When I try to use -fopenmp=libomp flag I am getting errors like this:
...: undefined reference to `__imp___kmpc_fork_call'
...: undefined reference to `__imp___kmpc_for_static_init_4'
...: undefined reference to `__imp___kmpc_for_static_fini'
...: undefined reference to `__imp___kmpc_barrier'
...
It all works without problems when compiling with GCC.
Is there a way to make it (openmp) work without Visual Studio installed? If no, is there some minimilastic Visual Studio installer which just pulls needed libraries/headers and not the whole IDE etc.?
I surely don't know what I am doing here. Explain like I am five answers are very appreciated.
What solved the issue for me was adding libomp.lib to the list of files to compile. This seems to be necessary no matter if I have -static in compiler options and no matter if it's:
-fopenmp=libomp
or
-fopenmp=libiomp5
(as the commenter suggested)
Summing things up, I needed:
clang --target x86_64-pc-windows-gnu -fopenmp=libomp ... C:\FULL\PATH\TO\libomp.lib
To make it work with MinGW-W64-builds-4.3.3 and Clang 5.0.1
Related
Im trying to link with a game library that has already been compiled using mingw, called Raylib. However; whenever I use MSYS's gcc 10.2 it gives me the following undefined reference error:
gcc main.c -Iraylib-3.7.0_win64_mingw-w64/include -Lraylib-3.7.0_win64_mingw-w64/lib -lraylib -lopengl32 -lgdi32 -lwinmm
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: raylib-3.7.0_win64_mingw-w64/lib/libraylib.a(core.o):core.c:(.text+0x1f6e): undefined reference to '_assert'
It seems that I maybe missing a library? This is just one of many similar errors. The majority of these undefined references are for assert like the one listed above. Some deal with GLFW and other libraries. Has anyone experienced something like this on MSYS?
Looks like I needed to be directly in MSYS2 mingw64 environment (cmd prompt). I was using the regular MSYS2 MSYS environment.
I am a novice to cmake and boost so this question might be missing something obvious:
I am building a project with cmake on linux (ubuntu) and I am trying to use boost logging in that project. Here is what I do to generate the Makefile:
rm CMakeCache.txt
cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-lboost_log -lboost_log_setup -lpthread -std=c++11" -DCMAKE_SHARED_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_MODULE_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_CXX_FLAGS="-DBOOST_LOG_DYN_LINK -std=c++11"
Compile goes through fine. (Some of these flags may be overkill -- I should only need the CMAKE_EXE_LINKER_FLAGS).
When I run the executable, I get the following unresolved reference:
-- ImportError: /home/mranga/gr-msod-sensor/gr-msod_sensor/build/lib/libgnuradio-msod_sensor.so: undefined symbol: _ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv
What flags am I missing? My boost library is set up and LD_LIBRARY_PATH points to the right location.
When I manually built a test program using the same linker flags, it compiles and runs fine so boost is installed correctly. I hope I have not missed the obvious.
(Moved question from the GNU Radio mailing list -- sorry if you are reading this post for a second time).
I believe the order of libraries in the linker command line in -DCMAKE_EXE_LINKER_FLAGS is incorrect. boost_log_setup depends on boost_log, so boost_log_setup should go first.
You seem to be linking against the non-multithreaded version:
-lboost_log
but the run-time linker seems to explicitely look for the multithreaded variant (the Boost doc site on that):
_ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv
^^
My guess hence is that you should try linking with
-lboost_log_mt
but the question whether that is right or not depends too much on your individual project to make it possible for me to clearly answer this.
OK, so I have been following this tutorial.
I set up everything as told (double checked everything), only thing I changed is (step 10), from
${OGRE_HOME}\boost_1_44
to
${OGRE_HOME}\boost
since in my Ogre SDK version (1.81), there is no boost_1_44 folder, only boost folder.
Anyhow, as I said, when I try to compile my program, I get this three errors :
undefined reference to boost::system::generic_category()
undefined reference to boost::system::generic_category()
undefined reference to boost::system::system_category()
I have tried adding this : -lboost_system to my Project. I went to Properties > C/C++ Build > Settings > GCC C++ Compiler > Miscellaneous and added it to the existing flags, but no luck.
I googled, and apparently that is the only solution possible. So, I ask you, if someone could explain me (as simple as possible please, step by step) how to fix this compiler errors.
EDIT : I'm using MinGW as a compiler (I use it with MSYS).
I have had similar problems compiling in linux using CMake and clang. I fixed it by adding the flag
-DBOOST_SYSTEM_NO_DEPRECATED
This "comments" out the lines causing the problem. I don't know if this will fix your errors but it did fix mine.
(If you use ./configure also add CPPFLAGS='-DBOOST_SYSTEM_NO_DEPRECATED' as a parameter).
So after searching the web for a while, Ive decided to try here as it seems to be a good forum for discussion. Im trying to create a simple gcc plugin. The program code is attached in the end of this mail, but in plain english it registers the plugin and makes sure that the pragma_init function is called when pragmas are registered. It is here that I use c_register_pragma to intercept some of the pragmas.
I compile it using the example in http://gcc.gnu.org/onlinedocs/gccint/Plugins-building.html#Plugins-building. The compilation and linking works fine. However, when I load the plug-in I get:
gcc -c -fplugin=plugin.so test.c -o test.o
cc1: error: cannot load plugin plugin.so
plugin.so: undefined symbol: warning
What am I doing wrong? In addition, when including some header files (that will be required later), I get a lot of errors. For example, including "tree.h" yields (amongst 50 other errors):
/machmode.h:262:1: error: unknown type name 'class'
class bit_field_mode_iterator
^
/machmode.h:263:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
/plugin/include/tree.h:27:0,
from conftest.c:63:
/vec.h:220:8: error: field 'register_overhead' declared as a function
Anyone have a clue on what I am doing wrong?
Thank you
There are two problems here :
The error : "cannot load plugin plugin.so" means that you should add to your LD_LIBRARY_PATH the directory where you store your new shared library plugin.
The hundreds of errors you got with all the files in the include are resolved in my computer if you compile with g++ instead of gcc (not sure to understand why thought)
Which version of GCC are you using, both to compile your plugin, and to use the plugin? Run simply
gcc -v
without any other program argument to find out!
Did you install the appropriate package for GCC plugin development (on Debian or Ubuntu, it might be gcc-4.7-plugin-dev, but adapt the 4.7 version to your particular version of GCC)?
Did you install all the dependencies needed to build your GCC (on Debian or Ubuntu, apt-get build-dep gcc-4.7 gcc-4.7-plugin-dev)?
Recent versions of GCC (notably many GCC 4.7 shipped by distributions, and all GCC 4.8) are compiled by a C++ compiler, not a C compiler.
You may check how was your GCC built (in C or in C++) by running
nm -D -C $(gcc -print-file-name=cc1)
If that command shows typed C++ manged names, e.g. execute_ipa_pass_list(opt_pass*) instead of just execute_ipa_pass_list your GCC has been compiled with a C++ compiler (probably g++)
So you may need to use g++ (not gcc) to compile your GCC plugin.
As I commented, did you consider using MELT (a domain specific language to extend GCC) to extend or customize your gcc compiler?
I suggest downloading the very latest http://gcc-melt.org/melt-plugin-snapshot.tar.bz2 since I will release the next MELT in a few weeks for GCC 4.7 and 4.8
And don't expect to change the parsing behavior of your GCC with a plugin. That is not really possible (GCC provides only plugin hooks to add your builtins and pragmas, not to extend the parsed syntax).
I'm using InstallJammer to build cross-platform installers for my application (Windows, Linux & Mac). However, InstallJammer development has been discontinued and the official forum is now closed.
I need to build the installkit for Windows, because I'll have to make some changes to the Windows install manifest, in order to add Windows 7 support (otherwise the installer displays the message "This program might not have installed correctly").
I grabbed the latest installkit sources from here: http://sourceforge.net/projects/installjammer/files/installkit/1.2.15/installkit-1.2.15.tar.gz/download
I found this topic http://www.installjammer.com/forums/viewtopic.php?f=3&p=9258 which helped me get started.
I grabbed latest version of MinGW and typed ./configure && make. It started the build process, but there was this error while trying to compile TCL:
c:/installkit-1.2.15/src/tcl/win/tclWinReg.c:750:29: error: lvalue required as increment operand
Since these sources are kind of old, I figured I should try with an older GCC version (I was using 4.7.2). So I downgraded MinGW's GCC to version 3.4.5 and tried again.
This time, TCL built fine. Everything was going well, until it failed to build something called 'miniarc' (I don't know what it is), with the following error message:
miniarc.o:miniarc.c:(.text+0x370c): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x37c9): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3cb6): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3e78): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3e9f): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3ff5): more undefined references to `_imp__strtoull' follow
collect2: ld returned 1 exit status
Strange thing is that there's no reference to imp_strtoull inside miniarc.c.
Moving on, I tried to build it in Ubuntu, since I didn't know what else to do, and it worked! GCC version was 4.4.3. So I went and searched for GCC 4.4.3 for MinGW, but the closest version was 4.4.0. I grabbed these and tried again. Same tcl build error (regarding tclWinReg.c).
Then I went back to GCC 4.7.2 and replaced TCL & TK sources (8.4) with the latest ones (8.5) and tried again.
TCL and TK both built fine, and so did some other libs, but when it came to 'miniarc', it failed again. This time with a different error:
undefined reference to `TclIncrVar2'
Apparently, this function no longer exists in TCL 8.5.
So, I'm out of ideas. I even tried emailing the original (and only) InstallJammer developer, but still got no answer (I don't even know if his email is the same).
Does anyone have any suggestions?
EDIT: I should add that I have very little experience with Makefiles and the last time I coded in C was 8 years ago in college. So, I apologize if there is something obvious about all this that I didn't notice.
I don't like the solution, but here's how I got it working:
Using GCC 3.4.5, I started the make process by typing ./configure && make;
The make process stops with an error (mentioned above) when it reaches 'miniarc';
Then, manually, I built a DLL (strtoull.dll) from file strtoull.o (below is the exact command-line I typed);
gcc -pipe -shared -o strtoull.dll strtoull.o -lz -L/c/installkit-1.2.15/Windows/lib /c/installkit-1.2.15/Windows/lib/libtclstub84s.a"
After that, I copied strtoull.dll to miniarc/build and to windows/system32;
Then I entered folder miniarc/build and typed:
gcc -pipe -shared -o miniarc01.dll miniarc.o sha1.o md5.o -lz -L/c/installkit-1.2.15/Windows/lib "/c/installkit-1.2.15/Windows/lib/libtclstub84s.a" strtoull.dll
Finally, I typed make again so it could continue building the rest of the stuff.