Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving from Windows to Ubuntu [closed]

I used to program in Windows with Microsoft Visual C++ and I need to make some of my portable programs (written in portable C++) to be cross-platform, or at least I can release a working version of my program for both Linux and Windows.

I am total newcomer in Linux application development (and rarely use the OS itself).

So, today, I installed Ubuntu 10.04 LTS (through Wubi) and equipped Code::Blocks with the g++ compiler as my main weapon. Then I compiled my very first Hello World linux program, and I confused about the output program.

I can run my program through the "Build and Run" menu option in Code::Blocks, but when I tried to launch the compiled application externally through a File Browser (in /media/MyNTFSPartition/MyProject/bin/Release; yes, I saved it in my NTFS partition), the program didn't show up.

Why? I ran out of idea.

I need to change my Windows and Microsoft Visual Studio mindset to Linux and Code::Blocks mindset.

So I came up with these questions:

  1. How can I execute my compiled linux programs externally (outside IDE)?
    • In Windows, I simply run the generated executable (.exe) file
  2. How can I distribute my linux application?
    • In Windows, I simply distribute the executable files with the corresponding DLL files (if any)
  3. What is the equivalent of LIBs (static library) and DLLs (dynamic library) in linux and how to use them?
    • In Windows/Visual Studio, I simply add the required libraries to the Additional Dependencies in the Project Settings, and my program will automatically link with the required static library(-ies)/DLLs.
  4. Is it possible to use the "binary form" of a C++ library (if provided) so that I wouldn't need to recompile the entire library source code?
    • In Windows, yes. Sometimes precompiled *.lib files are provided.
  5. If I want to create a wxWidgets application in Linux, which package should I pick for Ubuntu? wxGTK or wxX11? Can I run wxGTK program under X11?
    • In Windows, I use wxMSW, Of course.
  6. If question no. 4 is answered possible, are precompiled wxX11/wxGTK library exists out there? Haven't tried deep google search.
    • In Windows, there is a project called "wxPack" (http://wxpack.sourceforge.net/) that saves a lot of my time.

Sorry for asking many questions, but I am really confused on these linux development fundamentals.

Any kind of help would be appreciated =)

Thanks.

like image 572
Yana D. Nugraha Avatar asked May 02 '10 19:05

Yana D. Nugraha


2 Answers

How can I execute my compiled linux programs externally (outside IDE)? In Windows, I simply run the generated executable (.exe) file

On Linux you do the same. The only difference is that on Linux the current directory is by default not in PATH, so typically you do:

./myapp

If you add current dir to the path

PATH=".:$PATH"

then windows-like way

myapp

will do, but this is not recommended due to security risks, at least in shared environments (you don't want to run /tmp/ls left by somebody).

How can I distribute my linux application? In Windows, I simply distribute the executable files with the corresponding DLL files (if any)

If you are serious about distributing, you should probably learn about .deb (Ubuntu, Debian) and .rpm (RedHat, CentOS, SUSE). Those are "packages" which make it easy for the user to install the application using distribution-specific way.

There are also a few installer projects which work similarly to windows installer generators, but I recommend studying the former path first.

What is the equivalent of LIBs (static library) and DLLs (dynamic library) in linux and how to use them?

.a (static) and .so (dynamic). You use them in more or less the same way as on Windows, of course using gcc-specific compilation options. I don't use Code::Blocks so I don't know how their dialogs look like, in the end it is about adding -llibrary to the linking options (guess what: on windows it is about adding /llibrary ;-))

Is it possible to use the "binary form" of a C++ library (if provided) so that I wouldn't need to recompile the entire library source code?

Yes. And plenty of libraries are already present in distributions.

Note also that if you use .deb's and .rpm's for distribution, you can say "my app needs such and such libraries installed" and they will be installed from the distribution archives. And this is recommended way, in general you should NOT distribute your copy of the libraries.

If I want to create a wxWidgets application in Linux, which package should I pick for Ubuntu? wxGTK or wxX11? Can I run wxGTK program under X11?

Try wxGTK first, dialogs may look better, gnome themes should be used etc.

If question no. 4 is answered possible, are precompiled wxX11/wxGTK library exists out there? Haven't tried deep google search.

Try

apt-cache search wx

(or spawn your Ubuntu Software Center and search for wx)

In short: you will find everything you need in distribution archives.

like image 67
Mekk Avatar answered Nov 07 '22 09:11

Mekk


  1. Navigate to the folder with your compiled program and execute ./program
  2. Send the program, plus any .so files
  3. .a is static library, .so is shared libraries.
  4. Yes, but often you need to compile it yourself first.

Not sure about wxWidgets distributions, though.

like image 40
rlbond Avatar answered Nov 07 '22 08:11

rlbond