Extending PythonCE to Access gsm/camera/gps Easily from PythonCE - c

As it seems there is no scripting language for Windows mobile devices that gives access to phone (sms, mms, make a call, take photo). I wonder how complex it would be to make a Python library that would enable that (write something in C, compile, and import in PythonCE).
Question: Where shall start to understand how to compile a PythonCE module that will give additional functionality to Python on Windows mobile. Also, what is the required toolkit. Is it at all possible on Mac (Leopard)?

As the first step, you should try to create executable programs that invoke the functions you want. For example, to send SMS, it appears you need to call MailSwitchToAccount, passing "SMS", and so on - familiarize yourself with the C API on the platform.
To create executables, you need Visual Studio, and the Windows Mobile SDK. Those run on Windows. For cross-compilation, there is CeGCC (http://cegcc.sourceforge.net/docs/using.html), but using it probably makes things more complicated than using the Microsoft tools.
When you have executables that perform the functions you desire, creating Python extension modules out of them should be easy. Just follow the extending-and-embedding tutorials.

MSDN has plenty of samples for C++ development on Windows Mobile, and the SDK comes with several sample application. Unfortunately VS Express editions (the free ones) do not come with compilers for Smart Devices. The only free option is the older eMbedded Visual C++ (eVC), which is now something like 8 years old and not supported (though it can still create apps for devices at least up through CE 5.0).

just tried establishing an environment to get pythonce modules compiled (http://pythonce.sourceforge.net/Wikka/SConsBuild) but seems that I can only use 2003 PPC SDK and it has no recent functions available. Even when I followed all the steps in tutorial, sample spammodule.c does not compile :(
Is there any good tutorial I can utilize to startup C (C++) programming for Windows Mobile?
Also is it possible using free version of VisualStudio (Express version)?

Related

Porting a UNIX daemon to a Windows Service

I wrote a UNIX daemon, in C, which I want to port to Windows.
My target is Windows 10.
When I search on how to create a Windows service, I am met by an approach using .NET and C# which I both want to avoid at all cost.
How can I make a simple straightforward service in C, without kitchen sinks that Microsoft tries to unload on me? If I really have to, I would consider C++, but C# and .Net are simply taking it too far.
I'm fine with switching to a different compiler too, if this is easier outside of VisualStudio. (Currently I am using Visual Studio 2019, latest update.)
NOTE: My Linux daemon just has one dependency: libhidapi which is available for Windows.
UPDATE
No C++ templates available.
This comes down to creating two different applications (.exe)
One to run the service using StartServiceCtrlDispatcher() where the dispatching function calls RegisterServiceCtrlHandlerEx() to register a controller.
One to install the service using CreateService()
It is possible to skip on the installer, and use the sc command line utility for that, which is part of the OS.
See full example.

Compiling Windows PostgreSQL 9.5 64bit C-language functions

I want to create native C extensions to PostgreSQL 9.5 64bit on Windows.
I would love to build them with MinGW-w64 if that's possible, to get my build chain as clean as possible. But I am using the EnterpriseDB build of PostgreSQL, and MinGW build crashes it.
It would also be okay if there is another free compiler that I can use in this commercial project.
I know how to get this to work with Visual Studio 2003 Express but that doesn't seem to be a solution because of License issues.
Addition to the Main Answer
In the article linked below, you can read that it is possible to write C modules using Mingw or Cygwin, and some guidelines regarding the same. However I highly discourage doing so, mostly because of the reasons listed below, and also because that page mentions that those Windows configurations have special needs and receive lighter testing than most; expect a greater incidence of build problems
Here is the full excerpt on Unix-like Platform:
Unix-like Platforms
PGXS originated on Unix-like systems, and it is easy to use there. Unpack the extension module archive and run these commands in the resulting directory:
make PG_CONFIG=path_to_postgresql_installation/bin/pg_config
make PG_CONFIG=path_to_postgresql_installation/bin/pg_config install
You may omit the PG_CONFIG overrides if running type pg_config in your shell locates the correct PostgreSQL installation. Subject to the ownership of the existing PostgreSQL installation directories, the second command will often require root privileges. These instructions also apply when building for Windows using the MinGW or Cygwin compilers. However, those Windows configurations have special needs and receive lighter testing than most; expect a greater incidence of build problems.
A common mistake is to specify the PG_CONFIG=... on the command line before the 'make', which does not work as the value is then overridden by the inner workings of makefiles.
It's important to know that different compilers are not compatible with each other. Each of them have different runtime libraries. So it is very risky to compile extensions with a different compiler other than the one used to build the software you are using.
Postgresql's Windows build uses Visual Studio, same with EnterpriseDB (as far as I know). You will need to use the same compiler to build your extensions.
(For more information please refer: Building and Installing PostgreSQL Extension Modules and Postgres Enterprise Manager Installation Guide - EnterpriseDB (PDF))
This should explain why your extensions compiled with Mingw-w64 crash.
Luckily, there are two solutions you could choose:
Use Microsoft Visual Studio Community. It is completely free for individual developers, however there are restrictions for businesses. It should compile proper modules for your Postgresql build.
Rebuild the compleat Postgresql binary with Mingw-w64 or any other compiler of your choice (LLVM/Clang maybe), and then compile extensions with the same.
Doing either of these should help you. And this applies to all platforms, languages, and other softwares too. If you want to build extensions for a software, you need the same compiler, on the same platform used to build the software being used.
So, if you want to build extensions for Postgresql on Linux, you need the same compiler (probably GCC) to build extensions.
Happy coding =)
#Swith give you link to docs how to build PostgreSQL Extension Modules with Visual Studio and as you can read:
These instructions also apply when building for Windows using the MinGW or Cygwin compilers. However, those Windows configurations have special needs and receive lighter testing than most; expect a greater incidence of build problems.
A common mistake is to specify the PG_CONFIG=... on the command line before the 'make', which does not work as the value is then overridden by the inner workings of makefiles.
Did you check this ?
Also you can read other docs Building PostgreSQL With MinGW - maybe this help you more.
It would also be okay if there is another free compiler that I can use in this commercial project.
Did you check C compliers list on wiki - in particular, you can check Cygwin compiler - it's mentioned in docs above and it's free.
I know how to get this to work with Visual Studio 2003 Express but that doesn't seem to be a solution because of License issues.
What kind of issues do you see ?
Maybe check Visual Studio 2015 Community Edition (not Express) like #Simon Mourier suggest.
There is quite different licencing between Express and Community editions - I'm not sure about details, but as far I know Community Edition is more flexible for using in commercial projects:
For organizations:
An unlimited number of users within an organization can use Visual Studio Community for the following scenarios: in a classroom learning environment, for academic research, or for contributing to open source projects.
For all other usage scenarios:
In non-enterprise organizations, up to five users can use Visual Studio Community. In enterprise organizations (meaning those with >250 PCs or >$1 Million US Dollars in annual revenue), no use is permitted beyond the open source, academic research, and classroom learning environment scenarios described above.
For more information, see the Visual Studio Community license terms.

Multiplatform c project

I have to design a C project that is supposed to be run on Linux. I am very used to design C projects on Windows using Visual Studio or DevC++. Is it feasible to design the project on Windows and then port the code to Linux. Is it possible to use Eclipse CDT for switching compile configurations from Windows to Linux. What should i do? What do you suggest me to do or search?
This is a broad question since we have no info on what you're trying to achieve.
Some guidelines I can share with the limited information provided: in my experience it is feasible to write code on Windows and then port it to Linux although you should expect some differences in the Microsoft compiler and gcc compilers used in Linux/Unix (usually the more a compiler is conformant to the standard, the more it "warns" or won't accept something fishy in your code).
If you're dealing with a large number of dependencies / headers / source structures your project could greatly benefit from using a tool like CMake to deal with all those issues (a meta-generator that can generate makefiles and/or visual studio solutions depending on your platform from the same set of sources).
Also notice that you should NOT use any platform-dependent API in order to render your code portable. If you really need to, make sure to #ifdef those code sections for the specific platform you're compiling your code on.
Finally, if you plan to use a GUI in your application (or even if you're not planning one you might still benefit from the various libraries included), you might use a portable framework like Qt but keep in mind that this would require isolating the C part of your application from the C++ one (Qt). As another choice of your preference, you might also use GTK+.

Cloud9 IDE and C Programming

How can I write a C program in the IDE, cloud9? Whenever I start to write its showing errors, I even tried to change the file extension to ".C", but it doesn't work.
Does the cloud9 IDE support C programming?
Short answer
Yes Cloud9 does support C and C++ programming
Long Answer
Cloud9 has a varying level of support for different programming languages and frameworks.
Cloud9's ACE editor currently supports highlighting for about 60 programming languages including C/C++. The list is growing and you can get the full list from the "View -> Syntax" menu.
The editor has extensive support for JavaScript with error highlighting and code completion. It also has live syntax error checks for CSS, CoffeeScript, PHP, Python, JSON and Lua.
The run menu supports running
JavaScript (node.js)
Python
Ruby
PHP (using apache)
Each project is a unix sandbox with the standard tools like bash, make, gcc, vim, java SDK or perl installed. The terminal in Cloud9 is a full xterm compatible terminal emulator and you can use this to compile and run your C programs.
Cloud9 also has a package manager called c9pm which currently has about 120 packages. These packages include e.g. different versions of python and ruby, mono, lua or groovy.
In case you still need additional tools or libraries you can always download them to your workspace and compile and install them there.
As you see it is hard to draw the line of what is actually supported but usually you will have at least syntax highlighting in the editor and running from the console.
It claims support on the web page for "Javascript and Node.js applications as well as HTML, CSS, PHP, Java, Ruby and 23 other languages".
Yet it's very light on regarding details of those other languages. It does state that the editor, ACE, supports many different languages although whether that's natural languages or computer languages it doesn't specify. Additionally, an editor supporting a language is not the same as an IDE supporting it. It makes little sense having syntax coloring for C but no compiler.
Certainly C++ is possible as shown here but the fact that you simply use the editor then switch to a terminal session to compile the code seems to reduce the attractiveness of the so-called "IDE". It doesn't seem to give you anything you can't get from vim/gcc under Linux, or MinGW under Windows. It certainly isn't integrated in the sense that Visual Studio (even Express) or Code::Blocks is.
Regardless, the proper place for this sort of query is most likely on their support page here. I suspect they'd know more about what's supported than anyone here on SO.
Though I wouldn't be hopeful for a response. There's a very similar question asked back on Feb 28 which has still had no response. You have to wonder whether you want to entrust your precious code to a company that takes over four months to answer a simple support query.
In fact, to be brutally honest, I'm not sure I see the value proposition in using such a service. Given that you can get very good local IDEs already (for zero cost), the only possible advantage that springs to mind is collaboration. And, if you're working in a shop that has geographically dispersed developers, they'd probably have a fit if you told them you wanted to store your code where someone outside the company can get at it :-)
I'm not trying to turn you off the idea, just stating that (based on my experience), it doesn't seem as good as a substantial number of other solutions.
Cloud 9 does support C ( and C++ ) using gcc and g++
gcc --version
(GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
You can use their integrated editor, but the run button still acts like it trying to execute Javascript, which is the default, and seems to be their the target audience.
They have a fine C hello world example -- http://support.cloud9ide.com/entries/23541348-C-hello-Cloud9
Typically I just maximize the terminal, and run vim ( they have 7.2 installed ), and it works just like any passable unix terminal. They also have gdb installed, if you need a debugger.
There are comparisons against installed compiler solutions, but that isn't what Cloud9 is competing against. Their own description is Google Docs for code, and that seems to pretty fairly accurate. It certainly isn't all things to all people, but it is a pretty amazing service.
With Cloud9 I can write code on my Chromebook without having to install a bunch of stuff to almost make Linux run on it. This would be a good solution for students, since it would allow them to work in a computer lab without needing any software installed. I have found that using github and c9, I can easily switch back and forth between c9 while I am remote, and a local setup when I am on a real computer.

Porting C library to Java for Blackberry application

I need to port a C library to Java so it can run on the Blackberry platform (mobile, native application). The options I am considering are:
bytecode conversion (cibyl, etc)
Complete port
Wrap C code around Java using JNA (would this even work for Blackberry?)
Please let me know which option is best. thanks
Aha. Some quick googling says "No, JNI does not work for blackberry" source:
http://supportforums.blackberry.com/t5/Java-Development/Can-we-use-JNI-Java-Native-Interface-approach-in-Blackberry/m-p/365362
http://supportforums.blackberry.com/t5/Java-Development/JNI/m-p/41140.
So you're stuck with bytecode conversion and complete port. Since I have no idea what bytecode conversion is, I'd go with a complete port, so long as you are familiar with both languages. If you can define bytecode conversion for me, I might be able to give you a better answer.
We also have an in-house developed C library for core functionality of our iOS and Android apps.
I asked about using cibyl to run this on BlackBerry in the form of a .jar and the good news is that it's possible: https://twitter.com/#!/simonkagstrom/status/114581622833152000 [backup of the tweet: "Sure, that's how #waze on the blackberry works."]
You can also try MoSync: http://twitter.com/#!/MoSync/status/115088826430533632 [backup of this one: "Yup, you can use MoSync for BB. There's "experimental" Blackberry support in MoSync 2.6, already used in live apps!"]
And David A Roberts, developer of LLJVM sent me this: "I'm not familiar with BlackBerry development, but I see no obvious reason why LLJVM wouldn't work, so long as the library doesn't rely too much on things like the C POSIX library (e.g. dirent.h, etc) - I
never got around to implementing this fully. Otherwise LLJVM would need to be updated suitably..."
Side note: BlackBerry's new Tablet OS and planned BBX phones actually have a native SDK but this QNX based stuff is quite unpopular. We just need to wait if BBX is going to become a success since Java based solutions are just too much risks.

Resources