• 14
• 12
• 9
• 10
• 13

# from windows to linux

This topic is 3986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have write a program in VS2005 and now i want to compile on linux. How i can make Makefile and configure? TNX

##### Share on other sites
Check out SCons or CMake. Two great tools for cross platform development building. Much more joyfull to work with than autotools... :-) Just my opinion tho.

christer

##### Share on other sites
Quote:
 Original post by Xues32I have write a program in VS2005 and now i want to compile on linux. How i can make Makefile and configure?

I have yet to see a useful tool that will convert any of the several mutually-incompatible MSVC project files into a useful Makefile, let alone an autotools-compatible project.

You best bet is probably to learn one of the cross-platform build tools (there are many, some are better than others, google for them) and stick with that either for all-builds-but-Windows or else for all builds, using MSVC simply as a text editor. Many of the cross-platform tools will integrate the Microsoft C++ toolchain so you don't have to switch compilers.

If you want the classic GNU-style configure/make you'll need to use the GNU autotools. They have the distinct advantage that once ported to autotools, your project will build for any platform. No other build tool has that feature. No other build tool has the broad selection of arcane configuration languages and steep learning curve to get productive, either. It's a tradeoff, and you have to decide what you really want and what you're willing to pay for.

--smw

##### Share on other sites
To write a makefile, you have to understand a few things about the GCC/G++ compiler, specifically how to include libraries, includes, and set arguments. Makefiles are essentially glorified shell scripts. You can read more about them at the wiki: http://en.wikipedia.org/wiki/Make

Some important arguments you'll need in your makefile:

-c = compile file/class
-o <arg> = output to
-l<LIB> = use library
-wall = debug
$@ = Variable marker for the current make argument$^ = Variable marker for arguments after the ':'

For example, let's compile/link the main.cpp of a project. To set this up, the first line for our given argument is:

main.o : /source/path/main.cpp
g++ -wall -I/path/to/include $^ -c -o$@

Now, to link the executable in g++:

all : main.o
g++ -I/path/to/include -o app \$^ -l/path/to/lib1 -l/path/to/lib2