Port C Project from Windows to Linux [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am tasked with porting a massive c project from windows to linux. I have never ported anything over to linux before and am pretty new to linux. The project uses quite a bit of win32 calls. I have looked through some of it and understand what those parts do, however there are many moving parts and i feel it would take too much time to look through it all. What would be the best way to port it over? Is it foolish of me to think I can move the project over to the linux machine and work through the errors one by one?
Thank you in advanced!

Wine is a Windows Emulator for Linux, more exactly a re-implementation of the Windows API and binary interface, mainly for Unix-like OSes. It has also a builtin library named libwine, which is essentially a compatibility layer between the relevant Linux APIs (mainly: libc and X11) and the Win32.
Compiling the project with libwine, you will compile a Linux executable (binary), using the libwine as a shared lib (shared lib == dll). On this way, you can use the Windows API calls in a Linux project.
Your knowledge of the Win32 API helps a lot, most likely the compatibility isn't 100%. Probably you will have to modify the code a little bit (but not too much).

Related

Which programming languages can be used to make an operating system? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I was looking around bored for stuff to do, then I stumbled across a guide on making your own simple C & Assembly command line operating system.
Im just wondering, is it just major operating system that use things like C or can an operating system be created in other languages, like android with java.
The lowest level of an operating system is the kernel, it runs on the CPU, so the languages used can't depend on virtual machines or interpreters. Compilers create machine code from the language, and generally package the output in modules with well defined formats. Those modules can be used to create libraries, applications, or an operating system kernel. You need a language that lets you specify the module contents with a fair amount of control, a language like C is fairly easy, a language like C++ makes it much harder, so is not used for the low level of an operating system.
At the lowest level, you need complete control over the output, because it has to match the hardware, not a module format, so you use assembly language for that.
Above the kernel, there's a lot of stuff that uses higher level interfaces, so doesn't need to be a specific binary module, and can use an interpreter or virtual machine. Those levels can be in Java like Android is.
The original MacOS was written in a version of Pascal. Some IBM mainframe OSes used PL/1. Those are no longer popular, but both compiled into modules like C does.

How to create a multistage bootloader with asm and c? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a simple 32-bit text-based operating system.
Bootloader :
Firstly I want to create a multistage bootloader.
Stage 1 : Assembly code (NASM-Compiler)
Stage 2 : C (GCC-Compiler)
Kernel:
Then it should load Kernel which should be written in C (GCC-Compiler)
I would also like to know how to properly compile and execute it.
Emulator should be Qemu
A sample 32-bit Operating System that displays "Hello world" would be helpful.
Don't write your own bootloader. Configure and use an existing bootloader, probably GRUB. This would make using your toy OS much easier (both for you and for other users).
Read http://osdev.org/ since they have a lot of resources about OS building on PCs (including a hello world OS).
Read also some good operating system book (e.g. Operating Systems: Three Easy Pieces). You'll find out that there cannot be very simple OSes. See also this answer.
Also, be at least quite fluent with POSIX and with Linux system programming (read Advanced Linux Programming at first).

Windows programmer moving to linux - Coding conventions [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have been developing for Windows for a long time, mainly WinApi (and .Net).
I'v started learning basic Linux, and I have some questions regarding the differences:
In Windows I have barely used the C Standard library.
If I needed an API, I would search MSDN and find the appropriate library\function.
From what it seems like, in Linux the C Standard library is EVERYTHING.
All the code samples I have seen used the standard library (Instead of using some Linux internal functions, like a Linux "CreateFile").
Is this really how writing "proper" linux code is done ? Using the C standard library ?
If I wish to read a file, or allocate memory are fopen\malloc the way to go ?
If the answer to my first question is yes (And I guess it will be)
The C standard library is POWERLESS compared to the powerful WinApi.
Lets say I wish to get a list of running process (CreateToolhelp32Snapshot) or create a thread or a process (CreateThread\CreateProcess), How should I do that in Linux ?
Documentation.
In Windows, all I need can be found in MSDN.
If I have a "how do I do" question (Like the questions above) where should I go ?
Where is my main source of documentation.
Thanks a lot,
Michael.
Perhaps you've forgotten that the Standard C Library isn't environment-specific, it specifies least-common-denominator functionality among all systems that can run C programs, and C runs on systems that don't even have processes.
If you want an API that provides consistent common GUI/multithread/etc. APIs, pick a likely-looking GUI/multithread/etc. API. You might start with Qt, it's quite comprehensive and produces good-looking, near-native UIs on a host of systems.
It's not generally considered polite to point this out, but most questions that get asked publicly are asked by people who lack the discipline to do even simple research. Once people can do that, they don't need to ask very many, and that's why what you see is so ... trivial. You're past that. For more options, you could start here.
For more general-purpose tools, the top hit on a search for important linux tools might be helpful.

Which Linux distro uses Linux kernel as is with no modification [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to do some learning with Linux kernel and as you all know there is nothing better than playing with the code itself, Can you please let me know which one of the Linux distros is the easiest to work with? In other words, As far as I know Ubuntu for example modify the kernel for their distro, so the question again, which distro is using the Linux kernel as is with no modification?
Appreciate your guidance.
When it comes to no-frills (no external patches to the kernel) have a look at Slackware. Or follow "Linux from Scratch", that's as bare-bones as it gets.
If you want to start playing with the Linux kernel, I'd recommend a distribution which makes it particularily easy to compile the kernel yourself. Although I cannot provide detailed guidance, Gentoo seems to do so (although gentoo has other drawbacks, I don't know a single person in real life who actually used gentoo for more than two years).
I would not try and look for distributions not modifying the kernel, it's probably not worth the effort. Patches will probably be minor compared to the overall size of the kernel.
You can easily run Ubuntu for example with a vanilla kernel by following https://wiki.ubuntu.com/KernelTeam/GitKernelBuild.

Would an ARM Processor be the way to go? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was making a little device that would have three buttons (like the ones at radioshack) and each preform its own action. These buttons and their actions would be controlled by a very small real time operating system that I would put on this device.
Would I need an ARM Processor in any way?
How would I put the real time operating system on the device?
What OS would I have to compile this on (ex. Ubuntu? Mac OS X? Windows 7?)?
Are there any examples of anyone doing this?
P.S. No prebuilt boards (ex. arduino). I would build the board myself.
Any feedback would be greatly appreciated!
Even if you don't want to use a prebuilt board in the finished product, I'd recommend getting a prebuilt board (like the Arduino), build your product, program it, test it, etc. while on the breadboard, and then simply rebuild it however you want, using the same hardware as you've been using.
That helps you out especially the next time you're building something, because you already have the prototype board and the toolchain ready to go.
Compiling your files can be done on any OS.
Enumerated version:
No, and I wouldn't even recommend using an ARM processor; but rather an Atmega328 or similar.
Using a programmer.
Any.
Probably millions, or at least hundreds of thousands of examples, yes.

Resources