ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to start up programming (or learning programming) again. I am reading up on the KDeveloper package given that I can't find a Dev C++ for linux.
KDevelop looks pretty detailed but with a lot of capability. My concern is being KDE dependant. For me it's not a problem because I use Linux, but for other ppl I may want to share with will still be using Windows. So in short, my question is...
If I write something with KDeveloper and it has all the widgets and events being QT dependent, will I be able to use the code elsewhere or only in KDE?
Along the same lines, If I write a program that uses QT or allegro, why do I still need the libraries after it's compiled. Wouldn't compiling it to binary have the lib sections included, making the bin files independent?
If you stick to programming using libraries and functions/functionalities provided by Qt, you will be fine - it's when you incorporate the KDE-specific libraries (like IPC and application embedding) that it starts to become dependent on KDE.
You do not need the libraries - after compiling - only if you do a static compile. I don't know the option to pass to G++/GCC to statically link it - check the man page.
As for the binary files you are left with afterwards, they, alone are not system-independent simply because Window and Linux (and even BSD) all use different binary formats (byte-ordering, and the like). BSDs use a.out (at least, I think they still do), Linux uses ELF and I do not know what Windows uses, off the top of my head.
My opinion - for doing cross-platform programming - would be to write in Java; I suggest Java because of your, apparent, inclination towards C++ and I wanted to suggest a language with similar syntax. It's not a pretty language, but at least you know Java written on a Linux box will work on a Windows box, or an Apple box (only as long as you do not go near pathnames). In what little spare time I have, I am working on a portable pathname library for Java (I have not come across one, yet).
My only other choice for a language for cross-platform programming would be Common Lisp; but the syntax looks nothing like C or C++, or Java. It has a built-in portable pathname library.
Last edited by indienick; 01-16-2009 at 09:49 AM.
Reason: Lispaganda
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
Quote:
You do not need the libraries - after compiling - only if you do a static compile.
This is back to front. You DO need the libraries after compiling as the binary will dynamically link back to the shared library.
Compiling statically involves linking the library in to the binary. The library has to be a static version itself.
Quote:
As for the binary files you are left with afterwards, they, alone are not system-independent simply because Window and Linux (and even BSD) all use different binary formats (byte-ordering, and the like). BSDs use a.out (at least, I think they still do), Linux uses ELF and I do not know what Windows uses, off the top of my head.
It's not just the executable file format that is the problem. The underlying OS's are entirely different and system calls etc are not compatible across the platforms. Even if the file PE and ELF formats were compatible the binaries would not be cross-platform. T
What I was asking on the bin files, wasn't whether an EXE would work in Linux and I know the source would have to be compiled with the needed libraries under each OS. My question (after having installed several Linux packages with dependencies) is if I compile a program with the needed libs, and then take the executable of that compilation and move it to a different computer of the same OS. The machine I went to shouldn't need the libraries right? Wouldn't the compiler already have taken the needed functions with it during the compiling?
Along with that, if I compile a simply hello world program that used the QT libs for any event catching (mouse click buttons etc) If I then took that code to Windows and compiled it, wouldn't it fail? Or would I need a Windows version of QT before I could compile it?
Ace
Last edited by Ace Blackwell; 01-16-2009 at 10:29 AM.
Reason: Addendum (sp?)
Ok I think I'm getting it. But the original concern was with KDeveloper. I'm reading a tutorial (I know, just enough information to be confused) From the tutorial there is so much QT set up, version, CVS setup and things of this nature. My concern is with all this extra baggage, I wouldn't be able to use the code for anything but a Linux GUI enviroment.
Most compilers I'm used to (M$ Quick C, and Dev C++) just compiles the code you write and adds only what you tell it(from my novice perspective). But just to do a "Yo World" type program in KDeveloper requires a detailed lengthy set up that gerenates various files of classes and configurations, that I'm afraid will make the program unique to Linux?
Am I'm make any sense? LOL
Last edited by Ace Blackwell; 01-16-2009 at 10:49 AM.
Reason: files
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
Quote:
Along with that, if I compile a simply hello world program that used the QT libs for any event catching (mouse click buttons etc) If I then took that code to Windows and compiled it, wouldn't it fail? Or would I need a Windows version of QT before I could compile it?
If you have a Windows version of QT it will compile on Windows and work. This is why there are Windows versions of QT available. This is from the QT page here:
Quote:
Qt is a cross-platform application framework. Using Qt, you can write applications once and deploy them across many desktop and embedded operating systems without rewriting the source code.
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
Quote:
Most compilers I'm used to (M$ Quick C, and Dev C++) just compiles the code you write and adds only what you tell it(from my novice perspective). But just to do a "Yo World" type program in KDeveloper requires a detailed lengthy set up that gerenates various files of classes and configurations, that I'm afraid will make the program unique to Linux?
Don't confuse the files created by the IDE and version control system and the source code itself. The IDE may create config and Makefiles along with others but the basic source code (in your .c/.cpp) will be portable.
A bubble sort in KDevelop is a bubble sort in Visual Studio etc. it's just when you call OS/library dependent stuff the choice of platforms becomes limited.
Yes, yes. This is where most people (including myself) get a little fed up with IDEs.
If you want to do a simple "Yo World"-type of program, a text editor and an Xterm are your best bet.
All the stuff it's walking you through, is helping you set up things like Qt compatibility settings (because Qt is a cross-platform library) and CVS for code revision. Nothing in this should (theoretically) pin you to one platform.
Thanks guys, thats reassuring. I'll continue to read on in my tutorial. BTW there isn't a Dev C++ type compiler for Linux is there. I found one but requires buying the CD. Which I may do later if I can't find an alternative. I like the possibilities of KDev but at this time it really seems like overkill for my weak programs and tends to confuse me with all the added class work. I have to weed through numerous lines of code/files to look for my simple
cout<<"Yo World!!!";
Of course I could use your suggestion of a simple editor and command line compiling.
To run a native linux app on Windows, the libraries need to be available as Windows DLLs. A very substantial number of Linux libs are available this way, including the QT suite and the gtk suite of tools.
There are some differences between Linux source and Windows source, mostly having to do with system calls. I handle this with #define statements and #ifdef statements at appropriate places in the C++ (or C) code.
I am cross-compiling a project of mine that I am rewriting from end to end. The new version will run in Linux but my major market will be in Windows. I am developing using Kdevelop in Linux and cross-compiling for Windows using mingw, which is the gcc toolset used as a cross-compiler.
I have found that the best way to do this is to create a double sub-directory structure in my project directory; one structure for Linux and the other for Windows. I have hard-linked all the c, cc, h, and hh files between the two projects to ensure that the code remains constant. In the Linux directory structure, I use kdevelop; in the Windows directory structure I use a makefile.
A handful of files ARE different between the two projects; the Linux version doesn't support MSSQL and the Windows version doesn't support MYSQL (mostly because I can't get the interface code to compile correctly). Also, I have an include file called target.h which exists separately in both systems. The Windows version of this file says:
Thanks. This is a little advanced for me but I get the jest of it. And the skinny of the overall question is No, developing something in KDevelop doesn't lock it in to KDE or Linux.
If you want a slightly simpler IDE, and you are interested in QT then try QDevelop. It is an IDE for QT development, written using QT and so it is available in both Windows and Linux. You might find it easier to start with over KDevelop.
Well I've decided to try eclipse. I have it installed and of course it works great in Linux. It installed fine in Windows as well. I installed Cywin in Windows with gcc packages installed. The problem I have now is, how do I link the eclipse with gcc from Cywin? I run a simple program (YO World) but it won't build due to some make file issue. I believe its because it's not getting access to gcc. The reason I believe this is it is the same set of errors I was getting before I installed cywin and gcc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.