Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 交叉编译C++;Linux上以Windows为目标的MinGW代码:发生错误_C++_Linux_Mingw_Cross Compiling_Fltk - Fatal编程技术网

C++ 交叉编译C++;Linux上以Windows为目标的MinGW代码:发生错误

C++ 交叉编译C++;Linux上以Windows为目标的MinGW代码:发生错误,c++,linux,mingw,cross-compiling,fltk,C++,Linux,Mingw,Cross Compiling,Fltk,首先,我用g++(实际上是“fltk config--compile”)编译了以下代码,可执行文件在Linux上运行良好。但是,当我尝试在针对Windows的Linux上使用“mingw32”编译代码时,我遇到了错误: #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> int main(int argc,char**argv){ Fl_Window*Fl_Win

首先,我用g++(实际上是“fltk config--compile”)编译了以下代码,可执行文件在Linux上运行良好。但是,当我尝试在针对Windows的Linux上使用“mingw32”编译代码时,我遇到了错误:

#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, I mean, hello world!");
    Fl_Window_Ptr->end();
    Fl_Window_Ptr->show();
    return Fl::run();
}
发生以下错误:

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
但是,只需提及,以下命令很好,可执行文件在Linux环境中工作:

user@computer:~/Documents$ fltk-config --compile 2016_02_06a_1st_Window.cxx 
我的灵感来自。

正如“Ulrich Eckhardt”评论的那样,解决方案是修改backticks用法。最后,以下shell脚本解决了前面的错误:

#! /bin/bash
#This script compiles C++ source codes with MinGW32 with 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 and linking.."
i586-mingw32msvc-g++ $fltk_config_cxxflags $cxx_source $fltk_config_ldflags -o $exe_output
echo "End of script"
以前的错误现在已解决,但是,我遇到了一个新的错误找不到-lXext,可以在终端输出中看到:

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 and 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
现在我正在尝试解决新的错误

正如“Ulrich Eckhardt”所评论的,解决方案是修改backticks用法。最后,以下shell脚本解决了前面的错误:

#! /bin/bash
#This script compiles C++ source codes with MinGW32 with 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 and linking.."
i586-mingw32msvc-g++ $fltk_config_cxxflags $cxx_source $fltk_config_ldflags -o $exe_output
echo "End of script"
以前的错误现在已解决,但是,我遇到了一个新的错误找不到-lXext,可以在终端输出中看到:

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 and 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

现在我正在尝试解决新的错误

“'fltk-config--cxxflags'”-这可能有倒勾。当您解决这个问题时,命令行是什么?“'fltk-config--cxxflags'”-这可能会有反勾号。当您解决这个问题时,命令行是什么?您需要xext库-sudo apt get install xext devI假设为ubuntu/mint。如果您使用的是redhat/centos,请使用sudo-yum-install。。。。如果是SuSE,请使用sudo zypper安装…@cup谢谢,我将安装xext dev并重新构建。您需要xext库-sudo apt get install xext devI假设为ubuntu/mint。如果您使用的是redhat/centos,请使用sudo-yum-install。。。。如果使用SuSE,请使用sudo zypper安装…@cup谢谢,我将安装xext-dev并再次构建。