Pergunta

Estou procurando uma solução que me permita codificar o Linux e o Windows usando C ++.

No Windows, eu uso o Visual Studio (tentei outras coisas no Windows, mas trabalho com DirectX E até onde eu sei, é a melhor solução).

No Linux eu uso Netbeans (que eu gosto muito).

Meu problema é que quero que o projeto seja independente do Visual Studio e do NetBeans.

Por um tempo eu pensei que Cmake Foi a solução, no entanto, o processo de aprendizado é muito importante, prefiro passar meu tempo codificando do que aprender todos os truques com o CMake. Então eu decidi Boost.Jam. Funcionou bem no Linux, mas foi péssimo com o Visual Studio.

Criei um pequeno programa Hello World, no Windows. Criei um projeto Visual Studio Makefile e, enquanto ele está compilando e vinculando corretamente. Eu posso executar o executável, mas não do Visual Studio, que não consegue encontrar o executável (não importa o que eu faça). Eu também não posso depurar. Também não consigo ver a mensagem de erro de compilação quando conseguir uma. Tudo o que posso ver no Visual Studio é que existe uma ação makefile em andamento e que há um erro nisso (mesmo que o programa seja criado e corra bem).

Eu tenho navegado pela documentação do impulso. Tão poucos ouviram falar disso).

Eu tenho três perguntas:

Eu gostaria de saber se alguém ouviu falar de um projeto que usa Boost.Jam com o Visual Studio? Se sim, posso dar uma olhada?

Existe uma ferramenta por aí com integração real do Visual Studio?

Quantas pessoas pensam que aprender a usar o cmake (corretamente) custa muito tempo? Algum truque para acelerar?

Foi útil?

Solução

Você deve reservar um tempo para aprender cmake e acelerar o processo de aprendizado comprar/ler "Mastering Cmake 4th Edition"

Se você tiver problemas, deve usar o cmake Lista de correspondência, que é ativo (agosto de 2009 tinha ~ 600 mensagens)

Outras dicas

O criador QT e QT parece uma boa solução para o seu problema. O QMake pode gerar arquivos VCProj e o Linux Makefiles nativos.

Se eu fosse codificar em C ++ para Windows e Linux, codificaria o Linux e agruparia o aplicativo com uma configuração mínima de cygwin.

Are you sure you're looking at the right documentation? You have said "Boost.Jam", so chances are high you are looking at wrong thing. Please visit Boost.Build documentation

I am positively sure that many people used Boost.Build inside Visual Studio without problems. Can you try running the program on the command line -- maybe there's some error message that Visual Studio decides not to show?

I'd recommend CMake as well. It's a bit scary at first but you ease into it progressively. It's still rather easy for a beginner to write cross-platform scripts, even if they are not pretty or optimal as an expert would do. Integration with CppUnit (for unit tests) and Hudson (build mgt) made it possible to configure a Continuous Integration framework in no time.

I don't know much about NetBeans, but if you want to develop for both Windows and Linux and use Visual Studio on Windows, then CMake is the only sane choice, really. I've used it for several years now, and I cannot begin to guess how much time it has saved me maintaining makefiles and project files.

Upvote for Ben. We have a major vendor that did a Windows port of their old Unix code for commodity hardware access, and that's exactly what they did.

Emacs works fine on both platforms, as does GNU make. If you need a GUI, I'd use GTK+ with MinGW/msys rather than Cygnus and an X port.

I've seen a CMake demo at Fosdem a few months ago and it looked pretty impressive. I think it the time spent learning it may be worthwhile.

On the other hand, it is my personal experience that maintaining separate project files per platform is a perfectly acceptable way of doing things.

The only non-trivial thing about using CMake for cross-compilation is writing the toolchain information: CMake figures out the rest. See http://www.cmake.org/Wiki/CMake_Cross_Compiling#The_toolchain_file for more information.

I don't know how complex you wanna get, I use mingw-4.4.2 + cmake on linux to compile my Qt4 apps for windows, and NSIS on wine to create the setup files. Basicly I hacked my CMakeLists.txt to use mingw when I pass -DWin32=1. here's the relevent part :

if(WIN32) 
    SET(CMAKE_BUILD_TYPE "Release") #force release for win32, no motive to debug on win32

    SET(CMAKE_CXX_FLAGS_RELEASE  "-march=pentium4 -mtune=pentium4 -mwindows -DNDEBUG -mno-align-stringops -minline-stringops-dynamically -fno-ident -freorder-blocks-and-partition -finline-limit=700 -mfpmath=sse  -ftree-loop-distribution -floop-block -floop-interchange -floop-strip-mine -findirect-inlining -ftree-switch-conversion ${BASE_CXX_FLAGS}")

    SET(WIN32_BASE /home/win32-devel)
    SET(QT_LIB ${WIN32_BASE}/qt-win-opensource-src-4.5.3/lib/)

    SET(CMAKE_CXX_COMPILER i686-pc-mingw32-g++)
    SET(CMAKE_AR i686-pc-mingw32-ar)
    SET(CMAKE_RANLIB  i686-pc-mingw32-ranlib)
    SET(CMAKE_LINKER i686-pc-mingw32-ld)

    ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/app_icon.o
                        COMMAND i686-pc-mingw32-windres
                            -I${CMAKE_CURRENT_SOURCE_DIR}
                            -o${CMAKE_CURRENT_BINARY_DIR}/app_icon.o
                            -i${CMAKE_CURRENT_SOURCE_DIR}/icons/win32_icon.rc
                        )

    SET(OPENSSL_LIBRARIES  ${WIN32_BASE}/openssl-0.9.8l/libeay32.dll;${WIN32_BASE}/openssl-0.9.8l/libssl32.dll)
    SET(QT_LIBRARIES  ${QT_LIB}QtCore4.dll;${QT_LIB}/QtGui4.dll)
    SET(CMAKE_EXECUTABLE_SUFFIX ".exe")

    include_directories(${CMAKE_CURRENT_BINARY_DIR} ${QT_LIB}../include ${WIN32_BASE}/openssl-0.9.8l/include)
    message("Building For   : Win32")
else()
    include_directories(${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDES} ${OPENSSL_INCLUDE_DIR})
    message("Building For   : Linux")
endif()
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,--no-undefined -static-libgcc -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -s")

edit: Forgot to mention that actual development is done using KDevelop 4.

MPC, "the Makefile, Project, and Workspace Creator", is another tool that could be of use to you.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top