# C++ program only runable on FreeBSD?



## Sadakazu (Apr 1, 2017)

Hi, first of all, im the new one 
so here my question.... is it posible to check, wich os try to run a c++ programm, and stop it?

I'm pretty new on c++ developing... but i dont want, that my program can run on Windows or Linux

Any ideas?

Kind regards
Sada


----------



## tobik@ (Apr 1, 2017)

Sadakazu said:


> but i dont want, that my program can run on Windows or Linux


Why?


----------



## leebrown66 (Apr 1, 2017)

Well a windows executable isn't going to work on FreeBSD and vice versa so I don't see an issue there.  

I don't think Linux has a FreeBSD compatibility shim, so an executable compiled for FreeBSD can't work against a Linux kernel because the calling mechanism is different.


----------



## Sadakazu (Apr 1, 2017)

tobik@ 
Why not?? 
Well i'm verry new in c++ and i just asked me, is it posible? ^^

leebrown66 
So, when i compile the code on a (Free)BSD Compiler, i'll cant use it cross to Linux??

Whats about Development?
Can i develope the code on Linux in same way and just compile on bsd?
Are there different libs (headers) i have to use??

Like <iostream> or <fstream> and so on?? Or different Syntax?

Like i said.... i'm verry new on c++


----------



## leebrown66 (Apr 2, 2017)

If you compile a program on FreeBSD, no you can't copy the executable and run it under Linux (or Windows).

However you can copy the source to Linux and compile under Linux.  That executable will only run on Linux.
Provided you are using standard stuff, the libraries and headers are named the same, no change to code is needed.  Ditto for windows.

So absolutely yes, you can develop on Linux, then when you are happy, copy the source over to FreeBSD and compile it there.


----------



## Sadakazu (Apr 2, 2017)

perfect... thank you


----------



## Beastie (Apr 2, 2017)

These libraries are standardized so as long as your syntax and compiler are standard-compliant, you'll be fine.

Higher-level libraries such as Qt have also been ported to all major operating systems, so no problem there either.

If you want to develop under GNU/Linux you should avoid Linuxisms though.


----------

