undefined reference to ‘_imp__InitBizLib’ - c++

I am getting the error above when trying to use a 3rd party SDK with a C++ program written using eclipse on XP. Based on searches I understand that this error is caused by the linker not correctly pointing to the .dll or .lib. I have included the path to these items in the Environmental Variable - PATH, and also in eclipse under Properties\C/C++ Build\Settings\MinGW C++ Linker\Libraries. The path used for both of these items is C:\Program Files\Card Scanning Solutions\SDK
Here is the console output:
**** Build of configuration Debug for project HelloWorld ****
**** Internal Builder is used for build ****
g++ -IC:\Program Files\Card Scanning Solutions\SDK -O0 -g3 -Wall -c -fmessage-length=0 -lm -v -o src\BizScan.o ..\src\BizScan.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.1/configure --enable-languages=c,c++,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.1 (GCC)
COLLECT_GCC_OPTIONS='-I' 'C:\Program Files\Card Scanning Solutions\SDK' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\BizScan.o' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.6.1/cc1plus.exe -quiet -v -I C:\Program Files\Card Scanning Solutions\SDK -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.6.1/ -dD ..\src\BizScan.cpp -quiet -dumpbase BizScan.cpp -mtune=i386 -march=i386 -auxbase-strip src\BizScan.o -g3 -O0 -Wall -version -fmessage-length=0 -o C:\DOCUME~1\Game\LOCALS~1\Temp\ccwufpbm.s
GNU C++ (GCC) version 4.6.1 (mingw32)
compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65307
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.6.1/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.6.1/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
C:\Program Files\Card Scanning Solutions\SDK
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include-fixed
End of search list.
GNU C++ (GCC) version 4.6.1 (mingw32)
compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65307
Compiler executable checksum: 8e56a7b4b7f3db333ff95dd4b2d788a4
COLLECT_GCC_OPTIONS='-I' 'C:\Program Files\Card Scanning Solutions\SDK' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\BizScan.o' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/as.exe -o src\BizScan.o C:\DOCUME~1\Game\LOCALS~1\Temp\ccwufpbm.s
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.6.1/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.6.1/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../;/mingw/lib/
COLLECT_GCC_OPTIONS='-I' 'C:\Program Files\Card Scanning Solutions\SDK' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\BizScan.o' '-shared-libgcc' '-mtune=i386' '-march=i386'
g++ -LC:\Program Files\Card Scanning Solutions\SDK -lm -o HelloWorld.exe src\HelloWorld.o src\BizScan.o
src\BizScan.o: In function `ZN7BizScan4InitEv':
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:20: undefined reference to `_imp__UseFixedModel'
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:22: undefined reference to `_imp__SetTwainScanner'
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:23: undefined reference to `_imp__InitScanLib'
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:27: undefined reference to `_imp__InitImageLib'
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:31: undefined reference to `_imp__InitBizLib'
src\BizScan.o: In function `~BizScan':
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:39: undefined reference to `_imp__UnInitScanLib'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 5648 ms.
Here is BizScan.cpp:
/*
* BizScan.cpp
*
* Created on: Feb 13, 2012
* Author: TFB
*/
#include "BizScan.h"
#include "slibexp.h" // ScanLib SDK header file
#include "..\header_lib\BizExp.h" // ScanLib SDK header file
#include "..\header_lib\ImageExp.h" // ScanLib SDK header file
#include "CSSN.h"
#include "windef.h"
BizScan::BizScan() {
BizScan::Init();
}
const char* BizScan::Init() {
UseFixedModel(11);
const char *scannerSelected = "WIA-A6 Scanner 735";
int result = SetTwainScanner(scannerSelected);
result = InitScanLib(CSSN::GetSDKLicense().c_str());
if(result < 0 && result != -13){
return ScannerErrors(result);
} else {
result = InitImageLib(CSSN::GetSDKLicense().c_str());//initialize Image Lib SDK
if(result < 0 && result != -13)//if error
return ImageErrors(result);//call image lib sdk
result = InitBizLib(CSSN::GetSDKLicense().c_str());//initialize Biz Card Lib Scanner SDK
if(result < 0 && result != -13)//if error
return BizErrors(result);//call biz card scanner Lib SDK error handler
}
return "Successful Initialization !!";
}
BizScan::~BizScan() {
UnInitScanLib();
}
Here is BizScan.h:
/*
* BizScan.h
*
* Created on: Feb 13, 2012
* Author: TFB
*/
#ifndef BIZSCAN_H_
#define BIZSCAN_H_
#include "windef.h"
typedef HINSTANCE hDLL;
class BizScan {
private:
public:
BizScan();
virtual ~BizScan();
const char* Init() ;
};
#endif /* BIZSCAN_H_ */
And here is the relevant part of slibexp.h:
/*/////////////////////////////////////////////////////////////////////
//
// SLibExp.h
//
// Card Scanning Solutions (LLC)
// All Rights Reserved
//
/////////////////////////////////////////////////////////////////////*/
#ifndef SLIBEXP_H
#define SLIBEXP_H
#ifdef SDLL
#define SDLL_EXP __declspec( dllexport )
#else
#define SDLL_EXP __declspec( dllimport )
#endif
// Functions Prototypes
#if defined __cplusplus || defined c_plusplus
extern "C"
{
#endif
SDLL_EXP void UseFixedModel(int val);
SDLL_EXP short SetTwainScanner(const char *szStr);
SDLL_EXP short InitScanLib(const char * license);
IMAGE_EXPORT short InitImageLib(const char *licanse);
SDLL_EXP short UnInitScanLib();
#if defined __cplusplus || defined c_plusplus
};
#endif
#endif /* SLIBEXP_H */
The other two methods, referenced in the console output both are defined in other header files that are in the same folder (the project root directory). These are defined as follows:
IMAGE_EXPORT short InitImageLib(const char *licanse);
extern "C" BIZ_EXPORT short InitBizLib(const char *license);
Is there another place I need to link these .dll's. I have tried using the LoadLibrary() method, but that method gets rejected for not being part of the scope. How should I link to these dll's? Thank you for any direction you may offer.

Looking at the output you show, this is the relevant command:
g++ -LC:\Program Files\Card Scanning Solutions\SDK -lm -o HelloWorld.exe src\HelloWorld.o src\BizScan.o
It includes the path to the library, but there is no reference ro the actual library itself. I don't know what the name of the library is, but let's assume it's libBizLib.a, there should be -lBizLib at the end of that command; or if you want to link against the dll, you can use its full name (without -l).
(By the way, you mention a .lib extension of the library. That usually indicates a Visual Studio library. Are you sure the version you have, is compatible with MinGW?)

A similar issue happened to me recently. It appears to be because of the difference in compilers. Where the library was built with one version of MinGW w64, my version is different enough that I can't compile in the .a file that came with the library.
But you can use dll's at runtime using LoadLibrary, but you then have to be more explicit when calling it. Then the main ways the dll won't load is if the file isn't in the dll load path or if the dll is the wrong bit type (32 bit v 64 bit).
Hope that helps.

Related

'dllimport' attribute ignored and undefined reference errors while building wxWidgets with clang

I very need to build wxWidgets with clang on Windows for my current project, and I've build wxWidgets 3.0.3 and 3.1.0 on windows with native clang llvm 5.0.0, using mingw-w64 7.2.0, 64 bit, seh, posix threads standard library and tools (x86_64-w64-windows-gnu target). Samples are working. But I'm unable to link dll's except the main one. So I can't build opengl dll in monolithic shared build and all dlls with MONOLITHIC=0. There are some errors with headers/precompiled headers. While compiling I have many redeclared inline; 'dllimport' attribute ignored warnings like:
In file included from ../../src/xrc/xmlreshandler.cpp:18:
In file included from ..\..\include\wx/xrc/xmlreshandler.h:22:
In file included from ..\..\include\wx/window.h:18:
..\..\include\wx/event.h:3750:35: warning: 'wxObjectEventFunctor::operator()' redeclared inline; 'dllimport' attribute ignored [-Wignored-attributes]
inline void wxObjectEventFunctor::operator()(wxEvtHandler *handler, wxEvent& even
t)
and then linker undefined reference errors like:
clang_mswuddll-forest\coredll_appcmn.o:(.rdata[_ZTV12wxAppConsole]+0x1e0): undefined reference to `non-virtual thunk to wxAppConsoleBase::FilterEvent(wxEvent&)'
In case of monolithic build I had warnings in compilation stage only in file src/common/glcmn.cpp, so I had compiled a library with command like:
mingw32-make.exe -f makefile.gcc MONOLITHIC=1 SHARED=1 BUILD=debug USE_OPENGL=0 CFLAGS=" -Wno-inconsistent-missing-override -Wno-shift-negative-value -Wno-unused-command-line-argument " CXXFLAGS=" -Wno-inconsistent-missing-override -Wno-shift-negative-value -Wno-unused-command-line-argument -fexceptions -fasynchronous-unwind-tables -fnon-call-exceptions -std=gnu++11 -pthread " LDFLAGS=" -Wno-unused-command-line-argument -fexceptions -fasynchronous-unwind-tables -fnon-call-exceptions -pthread -Wl,--allow-multiple-definition " CC="clang -target x86_64-w64-windows-gnu" CXX="clang++ -target x86_64-w64-windows-gnu"
I had patched only two files while building wxWidgets 3.1.0 vesrion to avoid errors: include/wx/msw/private.h and src/msw/mediactrl_am.cpp
In src/msw/mediactrl_am.cpp I had changed the constant in case:
case -609: // readystatechange in IActiveMovie2 and IMediaPlayer
and in include/wx/msw/private.h I changed lines with errors:
// close the handle in the class dtor
//template <wxUIntPtr INVALID_VALUE = (wxUIntPtr)INVALID_HANDLE_VALUE>
template <wxUIntPtr INVALID_VALUE = (wxUIntPtr)-1>
class AutoHANDLE
and:
static HANDLE InvalidHandle()
{
//return static_cast<HANDLE>(INVALID_VALUE);
return reinterpret_cast<HANDLE>(INVALID_VALUE);
}
It is very difficult to me to install tools like MSYS2 on my job, so I would like to avoid using configure.
Is there a way to repair wxWidgets dlls building with clang in my case?

float.h not found or included properly when using mingw-w64

I'm trying to cross-compile a piece of code which uses float.h to set some FPU sizes.
The particular piece of code that requires it is:
#ifdef SINGLE
_control87(_PC_24, _MCW_PC); /* Set FPU control word for single precision. */
#else /* not SINGLE */
_control87(_PC_53, _MCW_PC); /* Set FPU control word for double precision. */
#endif /* not SINGLE */
When I compile, however, I get the error
/home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.c:4922:14: error: '_PC_53' undeclared (first use in this function)
_control87(_PC_53, _MCW_PC); /* Set FPU control word for double precision. */
Another person explains what seems to be the same problem in more detail here. There is also a very similar issue described in a (rather old) thread here. In case it's relevant, I'm using mingw-w64, but via the M Cross Environment
What exactly is the problem with float.h in this case, and is there a workaround?
EDIT: Verbose output from gcc
Using built-in specs.
COLLECT_GCC=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-gcc
Target: x86_64-w64-mingw32.shared
Configured with: /opt/mxe/tmp-gcc-x86_64-w64-mingw32.shared/gcc-4.9.4/configure --target=x86_64-w64-mingw32.shared --build=x86_64-unknown-linux-gnu --prefix=/opt/mxe/usr --libdir=/opt/mxe/usr/lib --enable-languages=c,c++,objc,fortran --enable-version-specific-runtime-libs --with-gcc --with-gnu-ld --with-gnu-as --disable-nls --disable-multilib --without-x --disable-win32-registry --enable-threads=win32 --enable-libgomp --with-gmp=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-isl=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-mpc=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-mpfr=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-cloog=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-as=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-as --with-ld=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-ld --with-nm=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-nm
Thread model: win32
gcc version 4.9.4 (GCC)
COLLECT_GCC_OPTIONS='-c' '-I' '../cfemm/fmesher' '-I' '../cfemm/libfemm' '-I' '../cfemm/libfemm/liblua' '-I' '/usr/local/MATLAB/R2015a/extern/include' '-I' '/usr/local/MATLAB/R2015a/simulink/include' '-D' 'MATLAB_MEX_FILE' '-std=c99' '-D' '_GNU_SOURCE' '-fexceptions' '-fPIC' '-fno-omit-frame-pointer' '-pthread' '-v' '-fpermissive' '-D' 'CPU86' '-D' 'MX_COMPAT_32' '-O' '-D' 'NDEBUG' '-o' '/home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.o' '-mtune=generic' '-march=x86-64'
/opt/mxe/usr/libexec/gcc/x86_64-w64-mingw32.shared/4.9.4/cc1 -quiet -v -I ../cfemm/fmesher -I ../cfemm/libfemm -I ../cfemm/libfemm/liblua -I /usr/local/MATLAB/R2015a/extern/include -I /usr/local/MATLAB/R2015a/simulink/include -D_REENTRANT -U_REENTRANT -D MATLAB_MEX_FILE -D _GNU_SOURCE -D CPU86 -D MX_COMPAT_32 -D NDEBUG /home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.c -quiet -dumpbase triangle.c -mtune=generic -march=x86-64 -auxbase-strip /home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.o -O -std=c99 -version -fexceptions -fPIC -fno-omit-frame-pointer -fpermissive -o /tmp/ccMkwwWD.s
cc1: warning: command line option '-fpermissive' is valid for C++/ObjC++ but not for C
GNU C (GCC) version 4.9.4 (x86_64-w64-mingw32.shared)
compiled by GNU C version 4.8.4, GMP version 6.1.1, MPFR version 3.1.4, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/../../../../x86_64-w64-mingw32.shared/sys-include"
#include "..." search starts here:
#include <...> search starts here:
../cfemm/fmesher
../cfemm/libfemm
../cfemm/libfemm/liblua
/usr/local/MATLAB/R2015a/extern/include
/usr/local/MATLAB/R2015a/simulink/include
/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/include
/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/include-fixed
/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/../../../../x86_64-w64-mingw32.shared/include
End of search list.
EDIT: more info
I also get the same result if I use the full directory path to the mingw-w64 float.h like so:
//#include <float.h>
#include "/opt/mxe/usr/x86_64-w64-mingw32.static/include/float.h"
EDIT more info on code structure
To give some further information, I am actually compiling C library (header and C file) where declaration of the function I'm using is included using extern C. The actual declaration from the header file is shown below:
#ifdef __cplusplus
extern "C" {
#endif
#ifdef ANSI_DECLARATORS
int triangulate(char *, struct triangulateio *, struct triangulateio *,
struct triangulateio *, int (*TriMessage)(const char * format, ...));
void trifree(VOID *memptr);
#else /* not ANSI_DECLARATORS */
int triangulate();
void trifree();
#endif /* not ANSI_DECLARATORS */
#ifdef __cplusplus
}
#endif
The actual library I'm using is Triangle. The float.h include is in triangle.c, and looks like this:
#ifdef CPU86
//#include <float.h>
#include "/opt/mxe/usr/x86_64-w64-mingw32.static/include/float.h"
#endif /* CPU86 */
#ifdef LINUX
#include <fpu_control.h>
#endif /* LINUX */
Where you define CPU86 or LINUX at compile time. For the cross build, I'm defining CPU86.
OK, after some searching around I found this in triangle.c:
/* On some machines, my exact arithmetic routines might be defeated by the */
/* use of internal extended precision floating-point registers. The best */
/* way to solve this problem is to set the floating-point registers to use */
/* single or double precision internally. On 80x86 processors, this may */
/* be accomplished by setting the CPU86 symbol for the Microsoft C */
/* compiler, or the LINUX symbol for the gcc compiler running on Linux. */
/* */
Note that it says "On 80x86 processors". The host you're compiling for - windows 64 bit (x86_64) - does not match that.
This is further supported by the official documentation from Microsoft about the extension that's used by the library you're trying to compile:
Mask
_MCW_PC (Precision control)
(Not supported on ARM or x64 platforms.)
[..]
_PC_24 (24 bits)
_PC_53 (53 bits)
_PC_64 (64 bits)
[..]
Thus I guess you need to configure your build differently, probably not defining CPU86. Though I don't know whether this really solves your issue, or just leads to wrong results. After all ... is this library even ported to 64 bit?

C++ Compile error on NetBSD '::system' has not been declared

I have some C++ code that compiles nicely on Linux but so far I'm having trouble getting it to compile correctly on NetBSD.
These are my includes:
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include <iomanip>
#include <boost/regex.hpp>
I compile with this command:
g++ -v -O2 -fno-strict-aliasing -I /usr/pkg/include \
barefoot.cpp -o barefoot -L /usr/pkg/lib/ -lboost_regex \
-L /usr/pkg/lib/ -lboost_regex -lpthreads
Which renders this output:
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64--netbsd
Configured with: /usr/src2/tools/gcc/../../external/gpl3/gcc/dist/configure --target=x86_64--netbsd --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20111202' --enable-__cxa_atexit --with-tune=nocona --with-mpc=/var/obj/mknative/amd64/usr/src2/destdir.amd64/usr --with-mpfr=/var/obj/mknative/amd64/usr/src2/destdir.amd64/usr --with-gmp=/var/obj/mknative/amd64/usr/src2/destdir.amd64/usr --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd5.99.56 --host=x86_64--netbsd
Thread model: posix
gcc version 4.5.3 (NetBSD nb2 20110806)
COLLECT_GCC_OPTIONS='-v' '-O2' '-fno-strict-aliasing' '-I' '/usr/pkg/include/' '-o' 'a.out' '-L' '/usr/pkg/lib/' '-mtune=nocona' '-march=x86-64'
/usr/libexec/cc1plus -quiet -v -I /usr/pkg/include/ barefoot.cpp -quiet -dumpbase barefoot.cpp -mtune=nocona -march=x86-64 -auxbase barefoot -O2 -version -fno-strict-aliasing -o /var/tmp//cc9Dcmwi.s
GNU C++ (NetBSD nb2 20110806) version 4.5.3 (x86_64--netbsd)
compiled by GNU C version 4.5.3, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.9
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=131007
#include "..." search starts here:
#include <...> search starts here:
/usr/pkg/include/
/usr/include/g++
/usr/include/g++/backward
/usr/include/gcc-4.5
/usr/include
End of search list.
GNU C++ (NetBSD nb2 20110806) version 4.5.3 (x86_64--netbsd)
compiled by GNU C version 4.5.3, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.9
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=131007
Compiler executable checksum: a34e7d170f4dd8d4687d2b62e8dca4b7
In file included from /usr/include/g++/bits/gthr.h:166:0,
from /usr/include/g++/ext/atomicity.h:34,
from /usr/include/g++/bits/ios_base.h:41,
from /usr/include/g++/ios:43,
from /usr/include/g++/istream:40,
from /usr/include/g++/fstream:40,
from barefoot.cpp:29:
/usr/include/g++/bits/gthr-default.h:130:9: error: 'pthread_detach' was not declared in this scope
/usr/include/g++/bits/gthr-default.h:130:1: error: invalid type in declaration before ';' token
/usr/include/g++/bits/gthr-default.h: In function 'int __gthread_detach(pthread_st*)':
/usr/include/g++/bits/gthr-default.h:668:46: error: '__gthrw_pthread_detach' cannot be used as a function
In file included from /usr/pkg/include/boost/regex/v4/regex_workaround.hpp:25:0,
from /usr/pkg/include/boost/regex/v4/regex.hpp:32,
from /usr/pkg/include/boost/regex.hpp:31,
from barefoot.cpp:32:
/usr/include/g++/cstdlib: At global scope:
/usr/include/g++/cstdlib:132:11: error: '::system' has not been declared
I tried adding -lpthread, but that resulted in the same output. Not sure what to try next.
I do not know exactly why you are facing this problem, but I can provide you with some next steps to try.
Notice that the first error is that pthread_detach is missing. The system header files will typically make sure whatever headers they need are included, but you can try adding <pthread.h> above all the other headers.
If that fails, you need to figure out which file got included as a result of adding #include <pthread.h>, and make sure pthread_detach is present inside it (it really should be there somewhere).
Assuming it is there, there must be some conditional compilation that is causing it to not be visible to your source code. Find the conditional guards, and what macro values affect it.
Then, you will need to see why your system is defining the macro values in a way that causes the function pthread_detach to not be visible.
With this investigation, you may discover that you are not including the right <pthread.h> file. This may be due to system include directories conflicting with the include directories you want to use.
This answer (it is towards the bottom) to this question shows how to display the predefined macros for the g++ compiler.

Building C++ file with g++ in Windows not working as .bat

Good morning,
I am a new user of Windows (+10 years using Linux) and for some reason I have to compile a C++ program. I do not have a big experience in debugging in Windows, but I am eager to understand what I do wrong.
I use MinGW with g++ and different libraries, particularly one called libjpeg.
When I compile & build the file in a PowerShell using the following command, everything works fine, and my C++ code gives me the expected results.
g++ -o imageProcessing imageProcessing.cpp -lgdi32 -Dgmic_use_jpeg -I'C:\GnuWin32\include' -L'C:\GnuWin32\lib' -ljpeg
When I use the exact same command in a .bat file, or directly in my C++ editor (geany), I have this error:
imageProcessing.cpp:6:21: fatal error: jpeglib.h: No such file or directory
#include <jpeglib.h>
^
compilation terminated.
It doesn't find the jpeglib.h.
The correct path were set in the environmental variables.
The libjpeg I use allows me to open/save jpeg pictures when I use the CImg library. It can be found here:
Jpeg for Windows
Here is a very simple example:
#include <iostream>
#include <jpeglib.h>
using namespace std;
int main() {
float number;
cout << "Enter a number: ";
cin >> number;
}
Let's call this test.cpp and its location is: C:\Users\Rémi\Documents\Image_Procesing\C++\testCImg
Here is what I've added in my environmental variables path: C:\GnuWin32\lib;C:\GnuWin32\bin;C:\MinGW\bin;
Here is my test.bat: g++ -o test test.cpp -lgdi32 -Dgmic_use_jpeg -I'C:\GnuWin32\include' -L'C:\GnuWin32\lib' -ljpeg
test.bat is also located in: C:\Users\Rémi\Documents\Image_Procesing\C++\testCImg
the .bat fail is the following:
C:\Users\Rémi\Documents\Image_Procesing\C++\testCImg>g++ -o test test.cpp -lgdi32 -Dgmic_use_jpeg -I'C:\GnuWin32\include
' -L'C:\GnuWin32\lib' -ljpeg
test.cpp:3:21: fatal error: jpeglib.h: No such file or directory
#include <jpeglib.h>
^
compilation terminated.
I spent all my day yesterday trying to figure it out, and I am limited by my Windows knowledge.
If someone could help me, I would appreciate it very much.
Thank you.
When you have include path problems, ask GCC to tell you what it's using.
In the below example, you can clearly see that it's searching for a location 'test' and ignoring it for not existing.
You can then deduce that, as mentioned elsewhere, the single quotes are wrong in Batch. At that point you'd give "test" a go and achieve success.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\lightness>g++ -E -x c++ - -v -I'test'
Using built-in specs.
COLLECT_GCC=g++
Target: mingw32
Configured with: ../../src/gcc-4.7.1/configure --build=mingw32 --enable-language
s=c,c++,ada,fortran,objc,obj-c++ --enable-threads=win32 --enable-libgomp --enabl
e-lto --enable-fully-dynamic-string --enable-libstdcxx-debug --enable-version-sp
ecific-runtime-libs --with-gnu-ld --disable-nls --disable-win32-registry --disab
le-symvers --disable-build-poststage1-with-cxx --disable-werror --prefix=/mingw3
2tdm --with-local-prefix=/mingw32tdm --enable-cxx-flags='-fno-function-sections
-fno-data-sections' --with-pkgversion=tdm-1 --enable-sjlj-exceptions --with-bugu
rl=http://tdm-gcc.tdragon.net/bugs
Thread model: win32
gcc version 4.7.1 (tdm-1)
COLLECT_GCC_OPTIONS='-E' '-v' '-I' ''\''test'\''' '-mtune=i386' '-march=i386'
c:/mingw32/bin/../libexec/gcc/mingw32/4.7.1/cc1plus.exe -E -quiet -v -I 'test'
-iprefix c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/ - -mtune=i386 -march=i386
ignoring nonexistent directory "c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/../../..
/../mingw32/include"
ignoring duplicate directory "c:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.1/inc
lude/c++"
ignoring duplicate directory "c:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.1/inc
lude/c++/mingw32"
ignoring duplicate directory "c:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.1/inc
lude/c++/backward"
ignoring duplicate directory "c:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.1/inc
lude"
ignoring duplicate directory "c:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.1/../
../../../include"
ignoring duplicate directory "c:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.1/inc
lude-fixed"
ignoring nonexistent directory "c:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.1/.
./../../../mingw32/include"
ignoring nonexistent directory "'test'"
#include "..." search starts here:
#include <...> search starts here:
c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/include/c++
c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/include/c++/mingw32
c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/include/c++/backward
c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/include
c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/../../../../include
c:\mingw32\bin\../lib/gcc/mingw32/4.7.1/include-fixed
End of search list.
# 1 "<stdin>"
Argument tokens in Windows traditionally use the " character. I'm thinking the single quotes are being interpreted as part of the path names, resulting in the "no such file or directory" errors. That would explain why it works in PowerShell, though, as single quotes are valid there.
See if you have better luck with this:
g++ -o imageProcessing imageProcessing.cpp -lgdi32 -Dgmic_use_jpeg -I"C:\GnuWin32\include" -L"C:\GnuWin32\lib" -ljpeg

I need help trying to compile a simple example for GLFW with MinGW

I am trying to compile an example from GLFW's documentation.
My folder structure for the libraries and source files are:
C:\cpp\
glfw3.dll glfw3dll.a libglfw3.a test.cpp
include\
GLFW\
glfw3.h glfw3native.h
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
I'm trying to compile it with this command
c:\cpp>x86_64-w64-mingw32-g++ -lglfw3 -Iinclude test.cpp -o test
but I get this error:
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lglfw3 collect2.exe: error: ld returned 1 exit status
-v outputs:
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=c:/users/username/gcc/bin/../libexec/gcc/x86_64-w64-ming
w32/4.7.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-4.7.2-mingw/configure --host=x86_64-w64-mingw32 --build=
x86_64-unknown-linux-gnu --target=x86_64-w64-mingw32 --prefix=/home/gfortran/gcc
-home/binary/mingw32/native/x86_64/gcc/4.7.2 --with-sysroot=/home/gfortran/gcc-h
ome/binary/mingw32/cross/x86_64/gcc/4.7.2 --with-gcc --with-gnu-ld --with-gnu-as
--with-gmp=/home/gfortran/gcc-home/binary/mingw32/native/x86_64/gmp --with-mpfr
=/home/gfortran/gcc-home/binary/mingw32/native/x86_64/mpfr --with-mpc=/home/gfor
tran/gcc-home/binary/mingw32/native/x86_64/mpc --with-cloog=/home/gfortran/gcc-h
ome/binary/mingw32/native/x86_64/cloog --with-ppl=/home/gfortran/gcc-home/binary
/mingw32/native/x86_64/ppl --with-host-libstdcxx='-lstdc++ -lsupc++ -lm' --enabl
e-cloog-backend=ppl --enable-targets=i686-w64-mingw32,x86_64-w64-mingw32 --enabl
e-lto --enable-languages=c,c++,fortran --enable-libgomp --enable-threads=win32 -
-enable-static --enable-shared=lto-plugin --enable-plugins --enable-ld=yes --ena
ble-libquadmath --enable-libquadmath-support --disable-nls --disable-tls --disab
le-win32-registry
Thread model: win32
gcc version 4.7.2 (GCC)
COLLECT_GCC_OPTIONS='-I' 'include' '-o' 'test.exe' '-v' '-mtune=generic' '-march
=x86-64'
c:/users/username/gcc/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.2/cc1plus.e
xe -quiet -v -I include -iprefix c:\users\username\gcc\bin\../lib/gcc/x86_64
-w64-mingw32/4.7.2/ -U_REENTRANT test.cpp -quiet -dumpbase test.cpp -mtune=gener
ic -march=x86-64 -auxbase test -version -o C:\Users\username~1.ADM\AppData\Local\T
emp\ccfe85gV.s
GNU C++ (GCC) version 4.7.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.0.0,
MPC version 0.9
warning: GMP header version 5.0.5 differs from library version 5.0.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/users/username/gcc/lib/gcc/../../lib/gcc/x8
6_64-w64-mingw32/4.7.2/../../../../include/c++/4.7.2"
ignoring duplicate directory "c:/users/username/gcc/lib/gcc/../../lib/gcc/x8
6_64-w64-mingw32/4.7.2/../../../../include/c++/4.7.2/x86_64-w64-mingw32"
ignoring duplicate directory "c:/users/username/gcc/lib/gcc/../../lib/gcc/x8
6_64-w64-mingw32/4.7.2/../../../../include/c++/4.7.2/backward"
ignoring duplicate directory "c:/users/username/gcc/lib/gcc/../../lib/gcc/x8
6_64-w64-mingw32/4.7.2/include"
ignoring nonexistent directory "/home/gfortran/gcc-home/binary/mingw32/cross/x86
_64/gcc/4.7.2/home/gfortran/gcc-home/binary/mingw32/native/x86_64/gcc/4.7.2/lib/
gcc/x86_64-w64-mingw32/4.7.2/../../../../include"
ignoring duplicate directory "c:/users/username/gcc/lib/gcc/../../lib/gcc/x8
6_64-w64-mingw32/4.7.2/include-fixed"
ignoring duplicate directory "c:/users/username/gcc/lib/gcc/../../lib/gcc/x8
6_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/home/gfortran/gcc-home/binary/mingw32/cross/x86
_64/gcc/4.7.2/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
include
c:\users\username\gcc\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../i
nclude/c++/4.7.2
c:\users\username\gcc\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../i
nclude/c++/4.7.2/x86_64-w64-mingw32
c:\users\username\gcc\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../i
nclude/c++/4.7.2/backward
c:\users\username\gcc\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/include
c:\users\username\gcc\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/include-fixed
c:\users\username\gcc\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x
86_64-w64-mingw32/include
End of search list.
GNU C++ (GCC) version 4.7.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.0.0,
MPC version 0.9
warning: GMP header version 5.0.5 differs from library version 5.0.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0b3cd9e378660c38a8a80567400ff92f
COLLECT_GCC_OPTIONS='-I' 'include' '-o' 'test.exe' '-v' '-mtune=generic' '-march
=x86-64'
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x
86_64-w64-mingw32/bin/as.exe -v -I include -o C:\Users\username~1.ADM\AppData\Loca
l\Temp\ccQqklHV.o C:\Users\username~1.ADM\AppData\Local\Temp\ccfe85gV.s
GNU assembler version 2.22.52 (x86_64-w64-mingw32) using BFD version (GNU Binuti
ls) 2.22.52.20120723
COMPILER_PATH=c:/users/username/gcc/bin/../libexec/gcc/x86_64-w64-mingw32/4.
7.2/;c:/users/username/gcc/bin/../libexec/gcc/;c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/bin/
EQ_LIBRARY_PATH=c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.
2/;c:/users/username/gcc/bin/../lib/gcc/;C:/Users/username/gcc/x86_64-w6
4-mingw32/lib/../lib/;c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw3
2/4.7.2/../../../../x86_64-w64-mingw32/lib/../lib/;c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../lib/;C:/Users/username/gcc/
x86_64-w64-mingw32/lib/;c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-ming
w32/4.7.2/../../../../x86_64-w64-mingw32/lib/;c:/users/username/gcc/bin/../l
ib/gcc/x86_64-w64-mingw32/4.7.2/../../../
COLLECT_GCC_OPTIONS='-I' 'include' '-o' 'test.exe' '-v' '-mtune=generic' '-march
=x86-64'
c:/users/username/gcc/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.2/collect2.
exe --sysroot=/home/gfortran/gcc-home/binary/mingw32/cross/x86_64/gcc/4.7.2 -m i
386pep -Bdynamic -o test.exe C:/Users/username/gcc/x86_64-w64-mingw32/lib/..
/lib/crt2.o C:/Users/username/gcc/x86_64-w64-mingw32/lib/../lib/crtbegin.o -
Lc:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2 -Lc:/users/
username/gcc/bin/../lib/gcc -LC:/Users/username/gcc/x86_64-w64-mingw32/lib
/../lib -Lc:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../.
./../../x86_64-w64-mingw32/lib/../lib -Lc:/users/username/gcc/bin/../lib/gcc
/x86_64-w64-mingw32/4.7.2/../../../../lib -LC:/Users/username/gcc/x86_64-w64
-mingw32/lib -Lc:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2
/../../../../x86_64-w64-mingw32/lib -Lc:/users/username/gcc/bin/../lib/gcc/x
86_64-w64-mingw32/4.7.2/../../.. C:\Users\username~1.ADM\AppData\Local\Temp\ccQqkl
HV.o -lglfw3 -lstdc++ -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -
lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt C:/Us
ers/username/gcc/x86_64-w64-mingw32/lib/../lib/crtend.o
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../lib/libglfw3.a when searching f
or -lglfw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../lib/glfw3.dll when searching fo
r -lglfw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../lib\libglfw3.a when searching f
or -lglfw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../libglfw3.a when searching for -lgl
fw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../glfw3.dll when searching for -lglf
w3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../..\libglfw3.a when searching for -lgl
fw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../lib/libglfw3.a when searching f
or -lglfw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../lib/glfw3.dll when searching fo
r -lglfw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../libglfw3.a when searching for -lgl
fw3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: skipping incompatible c:/users/username/gcc/bin
/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../glfw3.dll when searching for -lglf
w3
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: cannot find -lglfw3
collect2.exe: error: ld returned 1 exit status
c:\cpp>x86_64-w64-mingw32-g++ -Iinclude test.cpp -o test .\glfw3.dll
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `.\glfw3.dll' is in
compatible with i386:x86-64 output
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0xe): undefi
ned reference to `glfwInit'
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0x43): undef
ined reference to `glfwCreateWindow'
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0x53): undef
ined reference to `glfwTerminate'
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0x66): undef
ined reference to `glfwMakeContextCurrent'
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0x74): undef
ined reference to `glfwSwapBuffers'
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0x79): undef
ined reference to `glfwPollEvents'
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0x85): undef
ined reference to `glfwWindowShouldClose'
C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o:test.cpp:(.text+0x93): undef
ined reference to `glfwTerminate'
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: C:\Users\username~1.ADM\AppData\Local\Temp\cceVroaP.o
: bad reloc address 0x0 in section `.pdata'
c:/users/username/gcc/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x8
6_64-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
The order the library as it appears in the command line is important for gcc as well as the library search paths to look in. Try moving -lglfw3 to the end and add the current directory to the search path using -L.
eg.
g++ -Iinclude test.cpp -o test.exe -L . -lglfw3
Edit1: From looking at the verbose status output, it seems libglfw3.a that you have isn't compatible with the mingw gcc you're using. Luckily, the ld linker can work with dll files directly. See if the following works:
g++ -Iinclude test.cpp -o test.exe .\glfw3.dll
The alternative would be to create an import library from glfw3.dll using mingw gcc that you have. This is a bit more involved since you'd need create a .def file followed with a call to dlltool.
Edit2: The mingw gcc you're using is a 64-bit windows compiler. Make sure you're using the correct glfw3 64-bit library and not the 32-bit version. GLFW download section.
I think you have a naming problem. It seems Mingw32 compiler is looking for the library files glfw3.dll, glfw3.a and glfw3.h. The problem is that your library file is named libglfw3.a. Now you need to rename it to glfw3.a so that it can find it. If that still does not work then, you need to rename glfw3dll.a to glfw3.dll.a