Cross-compiling C++ code with MinGW on Linux, targetting Windows: error happens -


at first, compiled following code g++ (actually 'fltk-config --compile') , executable works fine on linux. when try compile code 'mingw32' on linux targeting windows, run errors:

#include <fl/fl.h> #include <fl/fl_window.h> #include <fl/fl_button.h> int main(int argc,char**argv){     fl_window*fl_window_ptr=new fl_window(400*1.618,400,"my second window");     fl_window_ptr->begin();     fl_button*fl_button_ptr=new fl_button(10,400-40,30*1.618,30,"hi, mean, hello world!");     fl_window_ptr->end();     fl_window_ptr->show();     return fl::run(); } 

when try compile 'mingw32' this:

user@computer:~/documents$ i586-mingw32msvc-g++ 'fltk-config --cxxflags' 2016_02_06a_1st_window.cxx 'fltk-config --ldflags' -o 2016_02_06a_1st_window.exe 

this error happens:

i586-mingw32msvc-g++: fltk-config --cxxflags: no such file or directory i586-mingw32msvc-g++: fltk-config --ldflags: no such file or directory 2016_02_06a_1st_window.cxx:1:19: error: fl/fl.h: no such file or directory 2016_02_06a_1st_window.cxx:2:26: error: fl/fl_window.h: no such file or directory 2016_02_06a_1st_window.cxx:3:26: error: fl/fl_button.h: no such file or directory 

however, mention, following command fine , executable works in linux environment:

user@computer:~/documents$ fltk-config --compile 2016_02_06a_1st_window.cxx  

i inspired this post.

as "ulrich eckhardt" commented, solution modify backticks usage. finally, following shell script resolved previous error:

#! /bin/bash #this script compiles c++ source codes mingw32 fltk compile/link flags echo "getting fltk-config --cxxflags.." fltk_config_cxxflags=$(fltk-config --cxxflags) echo "getting fltk-config --ldflags.." fltk_config_ldflags=$(fltk-config --ldflags) #echo $fltk_config_cxxflags #echo $fltk_config_ldflags cxx_source="2016_02_06a_1st_window.cxx" exe_output="2016_02_06a_1st_window.exe" echo "i586-mingw32msvc-g++ $fltk_config_cxxflags $cxx_source $fltk_config_ldflags -o $exe_output" echo "compiling , linking.." i586-mingw32msvc-g++ $fltk_config_cxxflags $cxx_source $fltk_config_ldflags -o $exe_output echo "end of script" 

the previous error resolved now, however, run new error of cannot find -lxext can seen among terminal output:

user@computer:~/documents$ ./2016_02_07a_script.sh  getting fltk-config --cxxflags.. getting fltk-config --ldflags.. i586-mingw32msvc-g++ -i/usr/local/include -i/usr/local/include/fl/images -i/usr/include/freetype2 -d_largefile_source -d_largefile64_source -d_file_offset_bits=64 -d_thread_safe -d_reentrant 2016_02_06a_1st_window.cxx -l/usr/local/lib -lfltk -lxext -lxft -lfontconfig -lpthread -ldl -lm -lx11 -o 2016_02_06a_1st_window.exe compiling , linking.. /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lxext collect2: ld returned 1 exit status end of script 

now i'm trying resolve new error!


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -