Linking against GLib using VS2017 - visual-studio-2017

I have msys2 installed on windows10, and I'm recompiling my linux projects to work on windows. So far, there is little problem, everything works fine when I compile using clang or gcc. But I'm unable to link using VS2017.
I can repro the issue with a hello world, basically, it's just this one line of code:
g_print ("Hello World\n");
and I get error
LNK2019: unresolved external symbol g_print referenced
Obviously, I have to tell the linker about glib, but how? I've tried pluging in C:\msys64\mingw64\lib and other likely folders into the linker properties, but I can't seem to find the magic incantation. I just keep getting the same error. What do I need to tell it? Or am I just wasting time on the impossible?

I got a better error message from VSCode - unable to find glib-2.0.lib.
Of course not, no such file exists. So I renamed libglib-2.0.dll.a to glib-2.0.lib, and renamed libintl.dll.a to intl.lib, and now it compiles, links, and runs just fine from VS2017.
This is a terrible solution. In my opinion, Gnome should supply better quality distros.

Related

How to solve eclipse cross-compilation c/c++ error. Symbol could not be resolved issue

I'm trying to make changes and compile open source 3d printers firmware in eclipse. Added all the project related to firmware but it showing symbol could not be resolved error. The cause of error is IDE cannot find the symbols. How can I solve this. It's compiling properly and also working on board.
Found the solution in indexer of the eclipse used active configuration settings and it solved all the Indexer error. Thanks for the help guys.

Eclipse with CDT not compiling at all

I have been trying out using Eclipse CDT for a course I am taking. Previously I have been using Visual Studio Express but since that requires me to be online and I have to use the IDE+compiler offline, I switched to Eclipse + Cygwin GCC.
Now everything was working prefectly, until I got an error about file paths in my make file. After reading some of the posts online, the issue seemed to be that Cygwin's make does not resolve absolute Windows file paths because of the ':' symbol and confuses it with a new target definition. The proposed fix was to download a fixed make file. I diligently did so and the programs would compile fine.
But after I went into the first debug session, everything froze. I aborted eclipse and tried a clean build but now the compilation wont happen AT ALL, which is very weird for me.
I can't find a post for a similar problem so I am really stuck now. I was currently working the assumption that my CDT may be corrupt or something so I downloaded Eclipse Luna just today and tried building using that, but no joy. Even a fresh project in a new workspace wont compile.
Appreciate the help in advance.
Did you try redownloading Eclipse? Sometimes Eclipse gets a fatal error glitch that makes it unable to compile anything. I've had this problem before, the only way i was able to fix it was to uninstall and re download the latest version. If this doesnt work, try switching to Bloodshed Dev C++ or codeblocks.
So it seems like an issue with the new make (v3.80). upgating it to v4.08 fixed the issue of not building.
Version 4.08 however does not fix the Windows file paths not being recognized properly and treated as a target definition. I am still getting the multiple target patterns. stop error.
EDIT: Found this on Stack overflow to solve the issue... should have searched better previously.
Very simple application fails with "multiple target patterns" from Eclipse

Compiling libffi with VS2012 fails with fatal error LNK1281: Unable to generate SAFESEH image

Compiling libffi with VS11 gives the following linker error
libffi\libffi-3.0.9\ms\Win32\Debug\ffi.dll : fatal error LNK1281: Unable to generate SAFESEH image.
The same project was compiling fine with VS10, but after an auto upgrade with VS2012, it started giving linker error
The Explanation in MSDN is too cryptic and least helpful
I might rebuild with /SAFESEH:NO , but I am unsure of the implication.
Please advise what might go wrong.
The main implication of not having SAFESEH is that your application won't be accepted for the Windows 8 store, or for Windows 8 desktop certification. If that's not an issue for you then feel free to use /SAFESEH:NO.
The documentation says:
The most common reason for the linker not to be able to produce an image is because one or more of the input files (modules) to the linker was not compatible with the safe exception handlers feature. A common reason for a module to not be compatible with safe exception handlers is because it was created with a compiler from a previous version of Visual C++.
Is it possible that the project upgrade to VS2012 changed the setting to /SAFESEH:YES. Perhaps you've never been building with SAFESEH.

STLPort, Intel compilers, build errors (though app runs fine!)

Compiling my project against STLPort I get some weird build errors. Weird, because the project runs just fine (and 20-30% faster) though you'd think the build errors would be fatal.
Can anyone enlighten me as to what I'm doing wrong and how to shut these up?
Linking... (Intel C++ Environment)
ipo: error #11017: Cannot open stlport_static.lib
ipo: error #11017: Cannot open libiomp5md
ipo: error #11017: Cannot open libmmt
ipo: error #11017: Cannot open libirc
ipo: error #11017: Cannot open svml_disp
ipo: error #11017: Cannot open libdecimal
ipo: warning #11020: unresolved ?_M_use_facet#locale#stlp_std##QBEPAVfacet#12#ABVid#12##Z
Referenced in ipo_19005obj.obj
[and lots of other unresolved symbols from that last .obj file]
(libiomp5md is from Intel's openmp support, I was using that before switching to stlport, and am still running with openmp now so don't see why that should have changed).
My runtime library (in C++ Code Generation settings) is set to multi-threaded.
Thanks in advance!
EDIT: it seems ipo is inter procedural optimization complaining that it can't open libraries which weren't compiled in the current build. So understandable that these errors aren't fatal, and my output still gets built. Still, any advice appreciated.
IPO is inter procedural optimization complaining that it can't open libraries which weren't compiled in the current build. These errors aren't fatal; the output still gets built but IPO obviously doesn't optimize the libraries it can't optimize.

Link error using Cygwin toolchain

I need to use Cygwin to compile C++ code for an Android project. I'm having trouble compiling even a basic "hello world" program. The console gives me this message:
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: unrecognized -a option `ware'
I've googled the error and the only result I've found was an issue with one of the programs (I think it was binutils) being out of date, and was resolved when that program was updated. I downloaded the entirety of the Cygwin package at once, so I don't think that's the problem. The compiler and linker aren't communicating properly. How do I fix it without changing compilers?
I figured it out - Android doesn't support the standard C++ library. Fixed by downloading http://www.crystax.net/android/ndk-r4.php
Which basically reimplements that for Android.