Export struct defined in winbase.h with ATL's IDL - windows-ce

This is my method defined in IDL:
[id(3), helpstring("method GetBatteryStatus")]
HRESULT GetBatteryStatus([out,retval] SYSTEM_POWER_STATUS_EX2* batteryStatus);
The SYSTEM_POWER_STATUS_EX2 is a struct defined in winbase.h, and this project is a ATLSmartPhone Project, the winbase.h is from Microsoft's SDK.
When I compile the project the error are :
error MIDL2025 : syntax error : expecting a type specification near "SYSTEM_POWER_STATUS_EX2"
If I add import "winbase.h" to the top of the IDL file, the error will be:
error MIDL2003 : redefinition : size_t; error MIDL2003 : redefinition : _LARGE_INTEGER;.....
Then if I add the typedef in in IDL:
typedef[public,uuid(37DE998A-6787-415a-A191-861C315D1248),helpstring("Power Status")]
struct _SYSTEM_POWER_STATUS_EX2 {
...
...
} SYSTEM_POWER_STATUS_EX2;
The error will be:
error C2011: '_SYSTEM_POWER_STATUS_EX2' : 'struct' type redefinition.
So how can I export the SYSTEM_POWER_STATUS_EX2 struct which was defined in winbase.h with IDL?

You can write the IDL version of the SYSTEM_POWER_STATUS_EX2 in the separate IDL file and import it for MIDL only:
cpp_quote("#if 0")
import "fake.idl";
cpp_quote("#else")
cpp_quote("#include <orginial_header>")
cpp_quote("#endif")

Related

Snappy not linking with rust

I was trying to follow the ffi example in the Rustnomicon.
I cloned the snappy repository and built it. I placed the snappy library inside the targets/debug/deps/ directory. Here is the code -
use libc::size_t;
#[link(name = "snappy", kind="static")]
extern "C" {
fn snappy_max_compressed_length(source_length: size_t) -> size_t;
}
fn main() {
let x = unsafe { snappy_max_compressed_length(100) };
println!("max compressed length of a 100 byte buffer: {}", x);
}
When I try to build it, it fails with this error -
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
snappy.lib(snappy.obj) : error LNK2019: unresolved external symbol __imp__invalid_parameter referenced in function "void * __cdecl std::_Allocate_manually_vector_aligned<struct std::_Default_allocate_traits>(unsigned __int64)" (??$_Allocate_manually_vector_aligned#U_Default_allocate_traits#std###std##YAPEAX_K#Z)
snappy.lib(snappy-stubs-internal.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
snappy.lib(snappy.obj) : error LNK2019: unresolved external symbol __imp__CrtDbgReport referenced in function "void * __cdecl std::_Allocate_manually_vector_aligned<struct std::_Default_allocate_traits>(unsigned __int64)" (??$_Allocate_manually_vector_aligned#U_Default_allocate_traits#std###std##YAPEAX_K#Z)
snappy.lib(snappy-stubs-internal.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReport
C:\Users\HP\Desktop\rust\c_interop\target\debug\deps\c_interop.exe : fatal error LNK1120: 2 unresolved externals

Facing error while using image_picker in flutter

Hy, I am new to flutter and while working with an app that uses image_picker to get images from the gallery I was facing this error.
C:\Users\Hrishabh Mishra\Desktop\FDR\Flutter\course\08\mycameraapp>flutter run
Launching lib\main.dart on Redmi Note 5 Pro in debug mode...
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:15: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:16: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:17: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerFileProvider.java:3: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerFileProvider.java:10: error: cannot find symbol
public class ImagePickerFileProvider extends FileProvider {}
^
symbol: class FileProvider
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerPlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:68: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY = 2342;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:69: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_TAKE_IMAGE_WITH_CAMERA = 2343;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:70: error: cannot find symbol
#VisibleForTesting static final int REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION = 2344;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:71: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CAMERA_IMAGE_PERMISSION = 2345;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:72: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_CHOOSE_VIDEO_FROM_GALLERY = 2352;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:73: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_TAKE_VIDEO_WITH_CAMERA = 2353;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:74: error: cannot find symbol
#VisibleForTesting static final int REQUEST_EXTERNAL_VIDEO_STORAGE_PERMISSION = 2354;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:75: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CAMERA_VIDEO_PERMISSION = 2355;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:77: error: cannot find symbol
#VisibleForTesting final String fileProviderName;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:164: error: cannot find symbol
#VisibleForTesting
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerPlugin.java:40: error: cannot find symbol
#VisibleForTesting
^
symbol: class VisibleForTesting
location: class ImagePickerPlugin
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:122: error: cannot find symbol
return ActivityCompat.checkSelfPermission(activity, permissionName)
^
symbol: variable ActivityCompat
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:128: error: cannot find symbol
ActivityCompat.requestPermissions(activity, new String[] {permissionName}, requestCode);
^
symbol: variable ActivityCompat
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:140: error: cannot find symbol
return FileProvider.getUriForFile(activity, fileProviderName, file);
^
symbol: variable FileProvider
20 errors
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':image_picker:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 28s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 32.5s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin image_picker...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 22.3s
WARNING: The option setting 'android.enableR8=true' is experimental and unsupported.
The current default is 'false'
Consider disabling R8 by removing 'android.enableR8=true' from your gradle.properties before publishing your app.
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'imagepicker'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 16s
The plugin image_picker could not be built due to the issue above.
SDK location not found. Define location with sdk.dir in the local.properties file or
with an ANDROID_HOME environment variable.
Configure the Android SDK first.
Method 1:
Go to Settings
Expand Language & Frameworks
Select Flutter
Enter the flutter sdk path in Flutter SDK Path textbox
Click Ok
Method 2:
Flutter provides a command to update the Android SDK path:
Use flutter config --android-sdk <path-to-your-android-sdk-path>

Error building CXX object gnuradio-runtime

I am trying to install a specific version of gnuradio (3.7.10.1). To do so I am not using Pybombs, but I try to do it from source (I am following this).
First I've cloned the github repository, then checkout the appropriate version. It worked fine until I've tried to invoke CMake and build GNU Radio:
mkdir build
cd build
cmake ../
make
During the make, after 6% done, I have the following error:
In file included from /usr/include/c++/7/type_traits:35:0,
from /usr/include/cppunit/tools/StringHelper.h:7,
from /usr/include/cppunit/TestAssert.h:8,
from /usr/include/cppunit/TestCase.h:6,
from /usr/include/cppunit/TestCaller.h:5,
from /usr/include/cppunit/extensions/HelperMacros.h:9,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^~~~~
In file included from /usr/include/cppunit/TestAssert.h:8:0,
from /usr/include/cppunit/TestCase.h:6,
from /usr/include/cppunit/TestCaller.h:5,
from /usr/include/cppunit/extensions/HelperMacros.h:9,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/tools/StringHelper.h:22:15: error: ‘enable_if’ in namespace ‘std’ does not name a template type
typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
^~~~~~~~~
/usr/include/cppunit/tools/StringHelper.h:22:24: error: expected unqualified-id before ‘<’ token
typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
^
/usr/include/cppunit/tools/StringHelper.h:31:15: error: ‘enable_if’ in namespace ‘std’ does not name a template type
typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)
^~~~~~~~~
/usr/include/cppunit/tools/StringHelper.h:31:24: error: expected unqualified-id before ‘<’ token
typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)
In file included from /usr/include/cppunit/TestCase.h:6:0,
from /usr/include/cppunit/TestCaller.h:5,
from /usr/include/cppunit/extensions/HelperMacros.h:9,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestAssert.h: In static member function ‘static std::__cxx11::string CppUnit::assertion_traits<T>::toString(const T&)’:
/usr/include/cppunit/TestAssert.h:74:42: error: ‘toString’ is not a member of ‘CppUnit::StringHelper’
return CPPUNIT_NS::StringHelper::toString(x);
^~~~~~~~
In file included from /usr/include/cppunit/extensions/HelperMacros.h:9:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestCaller.h: At global scope:
/usr/include/cppunit/TestCaller.h:159:37: error: ‘std::function’ has not been declared
TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
^~~~~~~~
/usr/include/cppunit/TestCaller.h:159:45: error: expected ‘,’ or ‘...’ before ‘<’ token
TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
^
/usr/include/cppunit/TestCaller.h:200:8: error: ‘function’ in namespace ‘std’ does not name a template type
std::function<void()> m_test_function;
^~~~~~~~
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod)’:
/usr/include/cppunit/TestCaller.h:121:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function( std::bind(test, m_fixture) )
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:121:28: error: ‘bind’ is not a member of ‘std’
m_test_function( std::bind(test, m_fixture) )
^~~~
/usr/include/cppunit/TestCaller.h:121:28: note: suggested alternative: ‘find’
m_test_function( std::bind(test, m_fixture) )
^~~~
find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod, Fixture&)’:
/usr/include/cppunit/TestCaller.h:138:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function( std::bind(test, &fixture) )
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:138:28: error: ‘bind’ is not a member of ‘std’
m_test_function( std::bind(test, &fixture) )
^~~~
/usr/include/cppunit/TestCaller.h:138:28: note: suggested alternative: ‘find’
m_test_function( std::bind(test, &fixture) )
^~~~
find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod, Fixture*)’:
/usr/include/cppunit/TestCaller.h:155:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function( std::bind(test, fixture) )
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:155:28: error: ‘bind’ is not a member of ‘std’
m_test_function( std::bind(test, fixture) )
^~~~
/usr/include/cppunit/TestCaller.h:155:28: note: suggested alternative: ‘find’
m_test_function( std::bind(test, fixture) )
^~~~
find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, int)’:
/usr/include/cppunit/TestCaller.h:162:17: error: ‘fixture’ was not declared in this scope
m_fixture(fixture),
^~~~~~~
/usr/include/cppunit/TestCaller.h:162:17: note: suggested alternative: ‘Fixture’
m_fixture(fixture),
^~~~~~~
Fixture
/usr/include/cppunit/TestCaller.h:163:7: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function(test_function)
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:163:23: error: ‘test_function’ was not declared in this scope
m_test_function(test_function)
^~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h: In member function ‘void CppUnit::TestCaller<Fixture>::runTest()’:
/usr/include/cppunit/TestCaller.h:175:7: error: there are no arguments to ‘m_test_function’ that depend on a template parameter, so a declaration of ‘m_test_function’ must be available [-fpermissive]
m_test_function();
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:175:7: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from /usr/include/cppunit/extensions/HelperMacros.h:14:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/extensions/TestNamer.h: In member function ‘std::__cxx11::string CppUnit::TestNamer::getTestNameFor(const string&, const E&) const’:
/usr/include/cppunit/extensions/TestNamer.h:70:95: error: ‘toString’ is not a member of ‘CppUnit::StringHelper’
return getTestNameFor(testMethodName) + " with parameter: " + CPPUNIT_NS::StringHelper::toString(val);
^~~~~~~~
In file included from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h: In static member function ‘static CppUnit::TestSuite* qa_fxpt::suite()’:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: ‘unique_ptr’ is not a member of ‘std’
CPPUNIT_TEST_SUITE_END();
^
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: expected primary-expression before ‘>’ token
CPPUNIT_TEST_SUITE_END();
^
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: ‘guard’ was not declared in this scope
CPPUNIT_TEST_SUITE_END();
^
In file included from /usr/include/cppunit/extensions/HelperMacros.h:9:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestCaller.h: In instantiation of ‘void CppUnit::TestCaller<Fixture>::runTest() [with Fixture = qa_fxpt]’:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:102:1: required from here
/usr/include/cppunit/TestCaller.h:175:22: error: ‘m_test_function’ was not declared in this scope
m_test_function();
~~~~~~~~~~~~~~~^~
/usr/include/cppunit/TestCaller.h:175:22: note: suggested alternative: ‘__fortify_function’
m_test_function();
~~~~~~~~~~~~~~~^~
__fortify_function
gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/build.make:62: recipe for target 'gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/math/qa_fxpt.cc.o' failed
make[2]: *** [gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/math/qa_fxpt.cc.o] Error 1
CMakeFiles/Makefile2:726: recipe for target 'gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/all' failed
make[1]: *** [gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
I am not a Linux expert and I am not very familiar to this compiler/library support. I don't really understand where the error comes from and how to correct it.
I use Ubuntu 18.04.
Coud you give me a hand on this please?
Any help would be very appreciated.
Thanks a lot.
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
To resolve the above error you need to compile with -std=c++11 flag. Open CMakeLists.txt, find all occurrences or -std=c++98 and change them to -std=c++11. Then go to the build directory, remove CMakeCache.txt and rebuild
sed -i 's/-std=c++98/-std=c++11/g' CMakeLists.txt
cd build
rm CMakeCache.txt
cmake ..
make
Also as the error is in the cppunit and it's used for testing you can try disabling all tests
cd build
rm CMakeCache.txt
cmake -DENABLE_TESTING=OFF ..
make

Simple Fltk application not cross-compiling with MinGW

I am trying to do cross-compiling on Linux to create exe file for 32bit Windows. I use following code:
i686-w64-mingw32-g++ rnfltk_simplest.cpp -static-libgcc -static-libstdc++ -o rnfltk_simplest.exe -lfltk -I/usr/include/
But I get an output with many errors:
In file included from /usr/share/mingw-w64/include/winsock.h:32:0,
from /usr/share/mingw-w64/include/windows.h:92,
from /usr/include/Fl/Fl_Window.H:26,
from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/_timeval.h:10:8: error: redefinition of ‘struct timeval’
struct timeval
^~~~~~~
In file included from /usr/include/sys/select.h:47:0,
from /usr/include/sys/types.h:219,
from /usr/include/stdlib.h:275,
from /usr/include/FL/fl_utf8.h:36,
from /usr/include/FL/Fl.H:32,
from rnfltk_simplest.cpp:2:
/usr/include/bits/time.h:30:8: error: previous definition of ‘struct timeval’
struct timeval
^~~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
from /usr/share/mingw-w64/include/windows.h:92,
from /usr/include/Fl/Fl_Window.H:26,
from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:21:16: error: using typedef-name ‘fd_set’ after ‘struct’
typedef struct fd_set
^~~~~~
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:275,
from /usr/include/FL/fl_utf8.h:36,
from /usr/include/FL/Fl.H:32,
from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
} fd_set;
^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
from /usr/share/mingw-w64/include/windows.h:92,
from /usr/include/Fl/Fl_Window.H:26,
from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:25:3: error: conflicting declaration ‘typedef int fd_set’
} fd_set;
^~~~~~
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:275,
from /usr/include/FL/fl_utf8.h:36,
from /usr/include/FL/Fl.H:32,
from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: previous declaration as ‘typedef struct fd_set fd_set’
} fd_set;
^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
from /usr/share/mingw-w64/include/windows.h:92,
from /usr/include/Fl/Fl_Window.H:26,
from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:104:16: error: using typedef-name ‘fd_set’ after ‘struct’
typedef struct fd_set FD_SET;
^~~~~~
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:275,
from /usr/include/FL/fl_utf8.h:36,
from /usr/include/FL/Fl.H:32,
from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
} fd_set;
^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
from /usr/share/mingw-w64/include/windows.h:92,
from /usr/include/Fl/Fl_Window.H:26,
from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:105:16: error: using typedef-name ‘fd_set’ after ‘struct’
typedef struct fd_set *PFD_SET;
^~~~~~
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:275,
from /usr/include/FL/fl_utf8.h:36,
from /usr/include/FL/Fl.H:32,
from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
} fd_set;
^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
from /usr/share/mingw-w64/include/windows.h:92,
from /usr/include/Fl/Fl_Window.H:26,
from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:106:16: error: using typedef-name ‘fd_set’ after ‘struct’
typedef struct fd_set *LPFD_SET;
^~~~~~
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:275,
from /usr/include/FL/fl_utf8.h:36,
from /usr/include/FL/Fl.H:32,
from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
} fd_set;
^~~~~~
In file included from /usr/share/mingw-w64/include/windows.h:92:0,
from /usr/include/Fl/Fl_Window.H:26,
from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/winsock.h:299:34: error: conflicting declaration of C function ‘int select(int, fd_set*, fd_set*, fd_set*, PTIMEVAL)’
WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
^~~~~~
In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:275,
from /usr/include/FL/fl_utf8.h:36,
from /usr/include/FL/Fl.H:32,
from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:108:12: note: previous declaration ‘int select(int, fd_set*, fd_set*, fd_set*, timeval*)’
extern int select (int __nfds, fd_set *__restrict __readfds,
^~~~~~
Where is the problem and how can it be solved? Thanks for your help.
The problem is in
-I/usr/include/
This path contains headers for libraries configured for and installed in your Linux system. But you want to use headers specific to the Windows libraries. These are installed in the MinGW compiler "system" include directory (most likely /usr/share/mingw-w64/include given that from there all the collisions come).
You need to install Fltk into your MinGW. For example, in openSUSE, this would be the package mingw64-fltk-devel.

Access a managed C++ lib from regular C++

I am trying to call a method in a managed C++ library from a regular (unmamanged) C++ file. I'm working from the example here (which is really good except for this little issue).
My managed C++ code is:
__declspec(dllexport) void ShowMessageBox(int *value)
{
AutoTagManagedBridge::Class1 work;
work.ShowCSharpMessageBox(value);
}
My unmanaged C++ code is:
_declspec(dllexport) void ShowMessageBox(int *value);
// ...
ACCB1 void ACCB2 MyPluginCommand(void *clientData)
{
int val = 5;
int *result = &val;
ShowMessageBox(result);
// ...
In the unmanaged C++ project, I set the managed C++ project as a reference. However, when I compile I get:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "void __cdecl
ShowMessageBox(int *)" (?ShowMessageBox##YAXPAH#Z) referenced in
function "void __cdecl MyPluginCommand(void *)"
(?MyPluginCommand##YAXPAX#Z) BasicPlugin C:\src\AdobePlugin\win32\BasicPlugin.obj 1
And when I look at the link command the managed C++ module (AutoTagManagedBridge.lib) is not listed:
/OUT:"Debug/BasicPlugin.api" /MANIFEST /NXCOMPAT
/PDB:".\Debug/BasicPlugin.pdb" /DYNAMICBASE "odbc32.lib"
"odbccp32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
"comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib"
"uuid.lib" /IMPLIB:".\Debug/BasicPlugin.lib" /DEBUG /DLL /MACHINE:X86
/SAFESEH /INCREMENTAL /PGD:".\Debug\BasicPlugin.pgd"
/SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:".\Debug\BasicPlugin.api.intermediate.manifest"
/ERRORREPORT:PROMPT /NOLOGO /TLBID:1
What else do I need to do?
Found the answer. In order for VisualStudio to recognize a .lib file from the Managed C++, you need to set on your UnManaged project right click and Properties -> ConfigurationProperties -> Linker -> Input ->
Additional Dependencies - > "$(SolutionDir)$(Configuration)\ManagedDll.lib".

Resources