Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ for Linux and Windows

51 views
Skip to first unread message

Jivanmukta

unread,
Feb 9, 2019, 10:08:52 AM2/9/19
to
I have little experience in C++. I am thinking about programming simple
PHP obfuscator in C++ for Linux and Windows. I would like to have same
source code for Linux and Windows (for easier maintenance of source
code). Is it good idea to have one project and to use preprocessor for
Linux/Windows differences? Which version of C++ I should use? Which C++
compilers? Windows version of my program should use GUI and compile to
32/64 bit binary, not .NET. Linux version should be command line tool.

Jivanmukta

unread,
Feb 9, 2019, 10:54:20 AM2/9/19
to
Thank you for your answer.

Paavo Helde

unread,
Feb 9, 2019, 11:00:07 AM2/9/19
to
On 9.02.2019 17:08, Jivanmukta wrote:


> Is it good idea to have one project and to use preprocessor for
> Linux/Windows differences?

No, peppering the code with #ifdef __linux__ is not a good way to go if
that's what you have in mind. Instead declare needed classes or
functions in a single header file whose implementation is provided in
separate implementation files for different platforms.

> Which version of C++ I should use?

C++11. Additions in later revisions are more cosmetic and not yet
universally supported, so may cause portability issues.

> Which C++ compilers?

You can use different compilers on each platform, e.g. gcc or clang in
Linux, MSVC on Windows. For debugging nothing beats MS Visual studio,
especially for beginners.

> Windows version of my program should use GUI and compile to
> 32/64 bit binary, not .NET. Linux version should be command line tool.

This is 3 projects, not one: one common base library providing the
actual functionality, one command-line executable and one GUI
executable. With such separation it might even be you do not need to
care about platform differences in the code at all, you just do not
build some project on some platform.

General portability notes: use UTF-8 for all strings internally, convert
to UTF-16 at the application border in Windows, i.e. use only wide
versions of the Windows API functions, e.g. MessageBoxW().


Jivanmukta

unread,
Feb 9, 2019, 11:22:49 AM2/9/19
to

David Brown

unread,
Feb 9, 2019, 1:14:34 PM2/9/19
to
Presumably you are familiar with PHP programming? Use PHP, not C++ - it
will be much easier. C++ is an excellent language for many purposes,
but it is a good deal more difficult for a text manipulation task like this.

Jivanmukta

unread,
Feb 9, 2019, 1:42:24 PM2/9/19
to
W dniu 09.02.2019 o 19:14, David Brown pisze:
> Presumably you are familiar with PHP programming?  Use PHP, not C++ - it
> will be much easier.  C++ is an excellent language for many purposes,
> but it is a good deal more difficult for a text manipulation task like
> this.
>

But I want to have Windows .exe and Linux executable binary file.
I think I decide for Python because I can use it for web-developement
which is my main activity.
Thanks for your answer.

David Brown

unread,
Feb 9, 2019, 3:35:43 PM2/9/19
to
On 09/02/2019 19:42, Jivanmukta wrote:
> W dniu 09.02.2019 o 19:14, David Brown pisze:
>> Presumably you are familiar with PHP programming?  Use PHP, not C++ -
>> it will be much easier.  C++ is an excellent language for many
>> purposes, but it is a good deal more difficult for a text manipulation
>> task like this.
>>
>
> But I want to have Windows .exe and Linux executable binary file.

Why? You can make an executable program in PHP, as long as PHP is
installed on the system (just like with Python). People often think PHP
only works in a web server, but that is not true.

However, Python is absolutely fine for the purpose, and probably better
than PHP - I only only suggested PHP because I thought perhaps you were
already familiar with the language.

Jivanmukta

unread,
Feb 11, 2019, 10:25:01 AM2/11/19
to
W dniu 09.02.2019 o 21:35, David Brown pisze:

> You can make an executable program in PHP, as long as PHP is
> installed on the system (just like with Python).  People often think PHP
> only works in a web server, but that is not true.
>
> However, Python is absolutely fine for the purpose, and probably better
> than PHP - I only only suggested PHP because I thought perhaps you were
> already familiar with the language.


Thus I choose PHP. I didn't know that I can produce .exe from PHP.
Thanks.

David Brown

unread,
Feb 11, 2019, 1:35:04 PM2/11/19
to
I don't know how you do it, but I expect it is possible in a similar way
to Python (where the Python runtime and libraries are packaged together
in one huge exe file). Alternatively, you can install PHP normally, and
just run the PHP files from the command line.

0 new messages