Can i create apple or android application using c? - c

I was wondering if i can create an application using C because android applications nowadays are programed using java and i don't have a lot of knowledge in Java programing

You can use something called the NDK to create statically linked libraries that Android can call. Remember these are linked libraries (.so files) and so they do not have a Main in the traditional sense. To find more information on that follow this link. http://developer.android.com/tools/sdk/ndk/index.html
It's important to note that you will still need to write some Java code but it allows you to do a lot of the non GUI work via C code.
On the flip side IOS programs are written in Objective-C which sounds similar to C but from what I've been told it's very far apart.

Related

Can I make an android game using OPEN GL ES with c language?

I saw that most OPEN GL ES resources are written in java. And i don't know java. Can I make an android game using OPEN GL ES with c language? Is this possible? If possible, will I have trouble in compiling and similar situations?
Note:I want to make a 2d game for android.
Yes you can. Use Android NDK - native developer kit for C/C++ developers: https://developer.android.com/ndk
The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++. For certain types of apps, this can help you reuse code libraries written in those languages.
Example:
https://developer.android.com/ndk/samples/sample_na
The native-activity sample resides under the NDK samples root, in folder native-activity. It is a very simple example of a purely native application, with no Java source code. In the absence of any Java source, the Java compiler still creates an executable stub for the virtual machine to run. The stub serves as a wrapper for the actual, native program, which is located in the .so file.

What is the win32 equivalent for mac?

The below link shows examples on how the Windows API works:
Module 1. Your First Windows Program
I am quite interested in how the Mac API looks like.
After doing some reading, I read a lot of things like XCode (Environment), Cocoa Framework, etc. However, I dont see any information about something like the Win32 API.
Doesn't Apple have a low level C API that is not based on Obective-C but just plain old C?
Your link points to a tutorial for the GUI components of Windows. In that case, the equivalent for OS X is indeed the Cocoa framework, which consists of the Foundation and AppKit libraries, which are Objective-C libraries.
Cocoa's control drawing is entirely local to the application. Therefore, the only way to build applications using controls is with Objective-C. Nothing stops you from building a C API on top of that; similar tactics have been used to build libraries like Qt or bindings to languages like Python and Ruby.
There is no plain C GUI API in OS X. There are low-level APIs (part of the Quartz graphics framework, aka the Core Graphics API) for dealing with the window manager to open the top-level windows, but these are either very complicated or completely undocumented. And even then, you'd be responsible for doing all the controls and input handling yourself. Update Some of the basic facilities that applications build on top of are also available through C APIs, namely Core Foundation, Core Graphics, Core Text, and Grand Central Dispatch. But these are still not enough to use Cocoa; Cocoa is just built on top of them.
There is also the Carbon API, which is a C API, but was intended for transitioning pre-OS X applications to OS X and is thus not suitable for new application development. In fact, I'm not even sure it is even supported anymore.
So you have two options if you want to write a GUI program for OS X in plain C:
find a wrapper library
give up and learn Objective-C, which sits on top of plain C anyway
If online tutorials, including Apple's official ones, don't suit you, the Big Nerd Ranch books on Cocoa development are good. Note that their beginner-oriented books are transitioning to the Swift language, but they have a separate book dedicated to teaching Objective-C as well.
You'll also need to know that OS X applications almost exclusively design their user interfaces using a graphical designer called Interface Builder, akin to the form designers in Visual Studio. With the Windows API, you can still get away with doing things by code, and a lot of people do so; with OS X, doing everything programmatically is difficult (but still possible).

Can native C programs be used in LibGDX?

I have a program in C which i would like to call and use it in LibGDX so that i can use it both for android and desktop. So can you suggest me methods to call a C file into LibGDX?
To be clear, I believe you have an app written in Java that uses Libgdx currently, and you would like to extend that app by including a C library and making calls out to the C library from the Java application.
Libgdx does not provide any special support for third-party libraries, native or Java. You will have to use the backend platform's APIs to call out to native code (JNI, NDK, etc).
You should be able to add your library to the Android and Desktop backend projects, and access it via a Platform Interface. It is probably not possible to use the GWT-backend (unless you have a C to Javascript compiler). For iOS you would need to build your library for iOS, and then figure out how to link it into the Xamarin (or robovm) build process for your app. While I'm going to assume this is possible, I suspect neither is easy to accomplish.

How to make window application in ANSI C?

Until now I've been only writing console applications but I need to write a simple window application for a school assignment.
Could somebody point me to a good tutorial how to create windows and other ordinary windows elements such as buttons, 2d graphs etc in ANSI C? is there some good library I should use?
I tried googling but there are no tutorial websites devoted to C.
If you can, I would also appreciate some example code.
Thank you.
By the way, I use Dec C++.
GTK is a good library to use, but may provide non-native looks under Windows. It looks great under GNU/Linux, especially using GNOME.
It is implemented in just C (Using the GObject Type System, part of the GLib library), so it will work great for your needs. There is also a RAD tool called Glade.
There's nothing in the ANSI C standard about windows. If you want to make a windowed application, you'll have to use platform-specific libraries (e.g. Win32, Cocoa, or X11), or some sort of cross-platform library that encapsulates that (e.g. SDL, wxWidgets, or many more).
Common places to start are Charles Petzold's Programming Windows and theForger's Win32 API Programming Tutorial.
However in most cases C is no longer the preferred language for Windows development. Object oriented technology is far better suited to GUI development, and with the introduction of MFC, C++ became the preferred language, and later with .Net, C# and C++/CLI.
The Win32 API can be hard work, much of MFC is little better than a Win32 API wrapper, the .Net framework however was designed from the ground up, and is less encumbered by the legacy of the Win32 API monster, and working with it tends to result in far greater productivity.
Either way, Dev-C++ is not a great tool for GUI development.
http://support.microsoft.com/kb/829488 which also talks how to create
Windows application: Creates a simple
Microsoft Windows-based application.
The application files include a
ProjectName.cpp file that contains a
_tWinMain function. You can use this type of application to perform
graphical user interface (GUI) based
programming.
As for tutorials... use MSDN. Win32 API is C. You don't need "Win32 ANSI C tutorial" - you need Win32 tutorial (for example http://www.winprog.org/tutorial/start.html, http://www.functionx.com/win32/Lesson01.htm) - unless, of course, you don't know ANSI C but then you just look for ANSI C tutorial. These subjects are independent.
There are lots of good libraries—too many for there to be an obvious choice without starting a religious war. I recommend that for your first library you learn something that will work on Windows, Linux, or OSX. Here are two good choices, not necessarily the best, but widely used and personal favorites:
Tcl/Tk. You write most of your application in the Tcl scripting language, but you can easily integrate your own ANSI C code into Tcl, which was designed from the beginning with such integration in mind. The Tk toolkit is very easy to learn, and you can write many simple GUIs in pure Tcl when you are getting started. Interactive, easy, and very well supported.
If you want to write everything in ANSI C, I don't know of any really simple choices, but I've been fairly happy with wxwidgets. All these tools have a pretty steep learning curve, however.
There are not many plain C GUI libraries as the strengths of the language lie elsewhere. Perhaps you should think about using a language with C bindings so you can still do the number crunching in C, but use something less painful for GUI development?
If you really want to stick to C, you can either use the OS' native API or the only current cross-platform C GUI lib I'm aware of: GTK+. If you don't really need a GUI but just graphical output, I'd go with SDL.
I suggest you download Microsoft Visual Studio 2008 Express Edition and use C#.Net.
As has been said, I suggest you use Winforms and switch to a .Net environment. It's 2009, and I think there are more suitable solutions to GUI's :P
Edit: Nvm, didn't see it was a school assignment.
However, here is a C++ guide on the Win32 API: http://www.relisoft.com/win32/index.htm

Can I make a GUI using NetBeans but implement functionality using C?

I want to use NetBeans to build the GUI for my project, but implement the functionality using C code. Is there any way I can make the C code run when a button in the GUI is clicked?
I believe you can use standard JNI with netbeans.
Here's a link for version 6.0, (http://www.netbeans.org/kb/60/cnd/beginning-jni-linux.html) which I hope still applies for 6.5.
Once you set up a basic JNI C-library with the appropriate headers, it's pretty easy to use from the java side. And once you have that much done, it's even possible to throw Java Exceptions from the C code (http://www.codeproject.com/KB/debug/jni_ex.aspx)
But you should take note that if you're sending a lot of data back and forth, the overhead of the JNI data passing could be greater than the gain of using C for your speed-critical sections.
Cheers
You could use Java Native Access (JNA), a new technology. With JNA, Java applications can dynamically access native libraries from Java without JNI. JNA allows you to call directly into native functions using natural Java method invocation.
The project home page is here:
https://jna.dev.java.net/
Wikimedia article:
http://en.wikipedia.org/wiki/Java_Native_Access

Resources