Compiling GWEN with CodeBlocks - windows

so, I'm trying to compile Gwen in Windows, for use with a project I have coming up. I downloaded the source from Garry's GitHub, and followed his instructions on building the compilation before importing it to Code::Blocks to compile. I import the .cbp file, start compiling, and after a few minutes I get:
Error: '_asm' was not declared in this scope.
The error comes from some code after a line containing #ifdef _WIN32.
Exact file: gwen.cpp, line 49.
More information:
OS: Windows 7 64bit.
Compiler: Latest gcc from the MinGW, 4.7.2 (MinGW32)

I think it is because MinGW doesn't understand the assembler, it should be asm for that compiler. I think this is cause by using _WIN32 instead of WIN32. The former is the platform and the latter is API.
Try changing it to:
void AssertCheck(bool b, const char* strMsg)
{
if (!b)
{
Msg("Assert: %s\n", strMsg);
#ifdef WIN32
MessageBoxA(NULL, strMsg, "Assert", MB_ICONEXCLAMATION|MB_OK);
_asm { int 3 }
#endif
}
}
EDIT: Alternatively you could try Gwork, which is a tidied up version of GWEN.

Related

Linking to the MariaDB C Connector from Rust fails on Windows

I am currently working on a Rust project that requires me to connect to a MariaDB server. I have decided to create Rust bindings for the officially provided C connector, which works just fine in linux, but not on Windows.
Since only the MSVC-binaries are provided as a download, which don't work due to linker issues between the Microsft linker and the MinGW linker used for Rust that cause the program to crash when the first function is called, I tried to compile the mariadb sources myself, but even though compilation under MinGW should work as of the 2.0 release of mariadb, it fails with
error: conflicting types for ssize_t
typedef SSIZE_T ssize_t
since it has already been defined in another file, and when I tried to simply remove the redefinition, other errors occured.
I tried to cross-compile it from Arch using the mingw-w64-mariadb-connector-c package, which did not show any compilation errors for the connector, but when I tested the binaries on windows, it threw an undefined reference linking error for every of my C-Function declarations, which look like this:
extern crate libc;
use self::libc::{c_int, /*...*/};
#[link(name="mariadb", kind="dylib")]
extern {
pub fn mysql_init(mysql: *const MYSQL) -> c_int;
// ...
}
I also tried this suggestion for the mysql-c-connector, but the same linker errors appeared.
I am using the newest rust nightlies and MinGW-w64 v4.9.1 (the same version as in the nightlies), both 32 bit.

Setting up Qt Creator 3.3.2 and openCV 2.4.11 on Windows

I have a configuration problem while compiling and building a program with Qt Creator and the imageprocessing library openCV on my Windows machine. OpenCV worked some time ago with Visual Studio, but now I want to build programs with Qt Creator. I am working with opencv-2.4.11 and Qt Creator 3.3.2
I started a new program and tried to compile the following code:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv/cv.h>
using namespace std;
using namespace cv;
int main()
{
cout << "Hello World!" << endl;
Mat Bild;
return 0;
}
This building process ends with the errors:
C:...\build-Test01-Desktop_Qt_5_4_1_MinGW_32bit-Debug\debug\main.o:-1: In function ZN2cv3MatD1Ev':
C:\opencv\build\include\opencv2\core\mat.hpp:278: Fehler: undefined reference tocv::fastFree(void*)'
C:...\build-Test01-Desktop_Qt_5_4_1_MinGW_32bit-Debug\debug\main.o:-1: In function ZN2cv3Mat7releaseEv':
C:\opencv\build\include\opencv2\core\mat.hpp:367: Fehler: undefined reference tocv::Mat::deallocate()'
collect2.exe:-1: Fehler: error: ld returned 1 exit status
My .pro file includes the “INCLUDEPATH” and the “LIBS”:
INCLUDEPATH += C:\opencv\build\include\ \
C:\opencv\sources\include\
LIBS += -L C:\opencv\build\x86\vc12\lib\
-lopencv_core2411\
-lopencv_calib3d2411\
-lopencv_highgui2411\
-lopencv_imgproc2411\
SOURCES += main.cpp
What am I doing wrong – why do I always get an error :( ?
I tried also different other ways to define the include folders and libs, but I was not able to compile the testcode.
Regards
matl
You are using MinGW compiler and OpenCV extraction doesn't contain libraries built by it. So, you'll have to manually build them using MinGW provided by Qt. Use the following post for help:
How to link opencv in QtCreator and use Qt library
Make sure you have all the environment variables for Qt, MinGW and OpenCV libraries set properly. With all these done you should be all set.
Hope this helps.

boost test on windows with mingw compiler error: putenv not declared

I'm trying to compile a library on windows with mingw, that uses boost.
I compiled boost with:
bootstrap mingw
b2 toolset=gcc
After that I build the library with cmake and mingw.
Building the dll itself works fine, but when I try to build the tests, I get:
C:/boost/boost_1_55_0/boost/test/utils/runtime/config.hpp:95:51: error: 'putenv'
was not declared in this scope
putenv( const_cast<char*>( fs.str().c_str() ) );
So the error comes from a boost header and I have no idea how to fix that.
The repo of what I'm trying to build: https://github.com/linges/daestruct
It uses c99 and c++11.
This seems to be a bug in boost. It has been happened to others, too:
https://github.com/BoostGSoC/boost.afio/commit/1b06855b6e20a01a3c4461c6d2d54e16eb3c8e21
The solution (or better: workaround) is to add the following lines before the inclusion of boost::test:
#ifdef __MINGW32__
// Mingw doesn't define putenv() needed by Boost.Test
extern int putenv(char*);
#endif

Using C++11 with Cocos2d-x for Android

The beginning of my issue is that I'm trying to use regular expressions in Cocos2d-x. For whatever reason, std::tr1::regex isn't working with C++98, so I'm trying to use std::regex with C++11 (along with some other C++11 features). This is working with iOS now, since it's really easy to change the version of C++ in Xcode, but I'm having all kinds of trouble getting this to work on Android.
I'm using the r8e version of the NDK with the gnustl_static library. I set the LOCAL_CPPFLAGS += -std=c++11 I've tried setting the toolchain version to clang (in addition to the default). Regardless of the toolchain, I am now able to compile my code, but it still crashes when I try to create a std::regex object std::regex reg1("[a-z][0-3]*"); It seems like some people are able to get C++11 to work with the Android NDK expanded library (not the "minimal C++ runtime support library"), but I can't figure it out. I've read lots of ideas and I've tried most of them, and I've seen some clues, such as the following from CHANGES.html in the NDK docs:
Patched GCC 4.4.3/4.6/4.7 libstdc++ to work with Clang in C++11
I don't know enough about how this all fits together, so could someone point me in the right direction? What am I missing here?
Open your Application.mk file and add following two lines at the end:
APP_CPPFLAGS += -std=c++11
NDK_TOOLCHAIN_VERSION=4.7
Note: As you mentioned that you are using NDK's version r8e the toolchain version you need is 4.7. If it is r9, you can set it to 4.8.
Hope this helps.
Alternatively, if you aren't restricted to using c++'s std::regex, you could try using standard C: regcomp() and regexec() .
Here a sample implementation (http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html):
#include <regex.h>
int match(const char *string, const char *pattern)
{
int status;
regex_t re;
if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
return(0); /* Report error. */
}
status = regexec(&re, string, (size_t) 0, NULL, 0);
regfree(&re);
if (status != 0) {
return(0); /* Report error. */
}
return(1);
}
In Your android.mk add
LOCAL_CPPFLAGS += -std=gnu++0x

Difference between gcc and g++ when running c++ program with boost library?

I wrote a c++ program using boost library in Xcode. Here is my code. It is very simple.
#include <iostream>
#include </usr/local/include/boost/math/special_functions/beta.hpp>
using namespace std;
using namespace boost::math;
int main (int argc, char * const argv[])
{
double a = 100.0;
double b = 100000.0;
double x = 0.3;
double result = beta(a, b, x);
cout << result << endl;
return 0;
}
But when I tried to build it in the Xcode, there popped up a lot of errors related to the library linking stuff. I noticed that the compiler that Xcode was using was "System Default: gcc 4.2". And all other options are gcc or LLVM gcc (I have no idea what this is).
I later tried to compile the file simply using terminal. Weird thing happened. If I compile it with g++, without any extra flags, the compilation completed successfully and the the program could be ran normally; but if I compile it with gcc, there are pages of errors.
So, to sum it up, while using g++, everything is OK; while using gcc, everything is not OK. Since the Xcode is using gcc, the program could not be compiled using Xcode.
(And I kind of need to use the Xcode because this is just a test program, I actually have a much bigger project to handle and I depend on the debugger of Xcode.)
So my question is, WHAT THE HELL is the difference between gcc and g++? Or how can I change the compiler of Xcode to g++?
gcc is a C compiler.
g++ is a C++ compiler.
You're trying to compile C++, ergo, you need to use a c++ compiler.
Googling "Using XCode for c++" brings up lots of results, but this one seemed fairly straightforward and had pictures:
https://www.cs.drexel.edu/~mcs171/Wi07/extras/xCode_Instructions/index.html
The gcc command compiles C files (although you can use -libstdc++) to link C++ files as well but I don't recommend it.
The g++ command works for C++ files which is why it worked in your case.
For XCode you have to change the compiler from GCC to G++ for it to successfully work.

Resources