Downloading Header Files - c

Where can i download the following header files for dev c
sys/types.h
sys/socket.h
netinet/in.h
arpa/inet.h
and also the structure
sockadder and it's derivatives?

I don't know why you need to download these specific files, since they should come with your compiler suite in most modern systems.
You should also keep in mind that they can be radically different depending on your platform and that those files often #include other non-standard files (which #include others and so on). This could make those files very hard to parse and understand.
That said, from some indeterminate version of Linux:
http://linux.die.net/include/sys/types.h
http://linux.die.net/include/sys/socket.h
http://linux.die.net/include/netinet/in.h
http://linux.die.net/include/arpa/inet.h
If you are going to replace missing files, consider getting/reinstalling a proper compiler suite and any developer packages your are missing.
If you want to look at the structure definitions you should definitely be looking at the documentation rather than the actual implementations. That way you avoid tying your code to private definitions e.t.c. that can change between systems.
EDIT:
Just to confirm some of my comments above, struct sockaddr for said version of Linux is defined piece-by-piece in:
http://linux.die.net/include/bits/socket.h
http://linux.die.net/include/bits/sockaddr.h

What SDK are you working with? For Linux you get these files as part of your core C sdk. For Windows it comes with the SDK as well. If you just want a quick and dirty look at some header files I use http://www.google.com/codesearch.

Those headers (not header files) are part of the implementation. They need not be real files.
If your implementation does not provide them, you're out of luck.
If your implementation provides them as real files and you deleted them, reinstalling the compiler might work.
If your implementation provides them as real files and you cannot reinstall the compiler your approach might work. Sorry, I have no idea where to download the files --- or why would anyone copy the files somewhere in the first place.

I'm assuming that you are trying to compile a source code for the *nix platform under another, such as Windows. This approach won't do you any good. Remember that you'll need the libraries of those headers and they are not portable.
Install a Virtual Machine with Ubuntu on your PC to do this kind of development.

do:
apt-get install gcc-4.2

Related

Finding C libraries not included by default

Coming from programming environments that support package managers, I experience a lot of discomfort installing and using libraries not included in the default project.
For example, #include <threads.h> triggers an error threads.h file not found. I found that the compiler looks for header files in /Library/Developer/CommandLineTools/usr/include/c++/v1 by issuing gcc -print-prog-name=cpp -v. I am not sure if this a complete folder list? How do I find the ones that it doesn't find by default? I am on OSX, but Windows solution is also desired.
The question doesn't really say whether you are building your own project, or someone else's, and whether you use an IDE or some build system. I'll try to give a generic answer suitable for most scenarios.
But first, it's header files, not libraries (which are a different kind of pain, by the way). You need to explicitly make them available to the compiler, unless they reside on a standard search path. Alas, it's a lot of manual work sometimes, especially when you need to build a third-party project with a ton of dependencies.
I am not sure if this a complete folder list?
Figuring out the standard include paths of your compiler can be tricky. Here's one question that has some hints: What are the GCC default include directories?
How do I find the ones that it doesn't find by default?
They may or may not be present on your machine. If they are, you'll have to find out where they are located. Otherwise you have to figure out what library they belong to, then download and unpack (and probably build) it. Either way, you will have to specify the path to that library's header files in your IDE (or Makefile, or whatever you use). Oh, and you need to make sure that the library version matches the version required by the project. Fun!
On macOS you can use third-party package managers (e.g. brew) to handle library installation for you.
pkg-config is not available on macOS, unless you install it from a third-party source.
If you are building your own project, a somewhat better solution is to use CMake and its find_package command. However, only libraries supported by CMake can be discovered this way. Fortunately, their collection of supported libraries is quite extensive, and you can make your own find_package scripts. Moreover, CMake is cross-platform, and it can handle versioning for you.

Fast Artificial Neural Network Library On Embedded Platform

Since this is my first question after years of finding answers in this site, id like to say a big thanks to everyone.
I want to use FANN in an embedded platform, and i am using UVision 4 to code in C.
Since i am a C/C++ rookie, i cant figure out if i can / how i can use that library.
When i try to simply include the files, i get this error:
FANN\fann.h(51): error: #5: cannot open source input file "sys/time.h": No such file or directory
which makes sense because i am not compiling for windows platform.
Can i use the FANN library for embedded C? If so, how to include it?
Thanks
You have to write your own "sys/time.h" for your embedded system. It must offer everything the original one does to be compatible with your external library. Wether you write one from scratch or wrap something around an existing code base which is compatible to your embedded device is up to you.
You can also have a look at this SO question.
If you're not compiling on windows you'll have no problem - simply include sys/time.h like this :
#include <sys/time.h>
Note the < and > character, these will make sure that your header is looked up within $PATH.
If your compiler still wont find that header you will need to install libc, on debian this can be done with tools like apt-get

How convert file. a to .c or other extension? I need read file .a

Good day, I am working with Codeblock IDE under Windows in C language and I got the static library in file ".a" with the development of some functions. I must see somehow the code of the functions in the file because i need.
I was reading a lot on the forum but I could not solve my doubt.
someone could help? Tanks!!
(People said that this should be an answer, so here it is!)
*.a files are compiled libraries on Windows (the file extension is different on different operating systems). You can't see the source code unless you decompile it (which is very hard or impossible).
(From another comment) However, if the library is from an open-source project, then you might be able to find the source code.

Including third-party libraries in C applications

I'm a bit naive when it comes to application development in C. I've been writing a lot of code for a programming language I'm working on and I want to include stuff from ICU (for internationalization and unicode support).
The problem is, I'm just not sure if there are any conventions for including a third party library. for something like readline where lots of systems are probably going to have it installed already, it's safe to just link to it (I think). But what about if I wanted to include a version of the library in my own code? Is this common or am I thinking about this all wrong?
If your code requires 3rd party libraries, you need to check for them before you build. On Linux, at least with open-source, the canonical way to do this is to use Autotools to write a configure script that looks for both the presence of libraries and how to use them. Thankfully this is pretty automated and there are tons of examples. Basically you write a configure.ac (and/or a Makefile.am) which are the source files for autoconf and automake respectively. They're transformed into configure and Makefile.in, and ./configure conditionally builds the Makefile with any configure-time options you specify.
Note that this is really only for Linux. I guess the canonical way to do it on Windows is with a project file for an IDE...
If it is a .lib and it has no runtime linked libraries it gets complied into you code. If you need to link to dynamic libraries you will have to assure they are there provide a installer or point the user to where they can obtain them.
If you are talking about shipping your software off to end users and are worried about dependencies - you have to provide them correct packages/installers that include the dependencies needed to run your software, or otherwise make sure the user can get them (subject to local laws, export laws, etc, etc, etc, but that's all about licensing).
You could build your software and statically link in ICU and whatever else you use, or you can ship your software and the ICU shared libraries.
It depends on the OS you're targeting. For Linux and Unix system, you will typically see dynamic linking, so the application will use the library that is already installed on the system. If you do this, that means it's up to the user to obtain the library if they don't already have it. Package managers in Linux will do this for you if you package your application in the distro's package format.
On Windows you typically see static linking, which means the application bundles the library and it will use that specific version. many different applications may use the same library but include their own version. So you can have many copies of the library floating around on your system.
The problem with shipping a copy of the library with your code is that you don't get the benefit of the library's maintainers' bug fixes for free. Obscure, small, and unsupported libraries are generally worth linking statically. Otherwise I'd just add the dependency and ensure that whatever packages you ship indicate it appropriately.

How to build executable from c written source files?

There is few files with .c anf .h extensions (cmdline.c cmdline.h core.c core.h and so on) in src directory, also there is one file "MakeFile" without extension. Is there any possibility to build these source files into some executable file on Windows 7 (64bits) ? I think i need to download compilers for C or some sdks right?
Yes.
You need to:
download and install a C/C++ compiler (I recommend TDragon's distribution of MinGW ),
add the compiler to your PATH (the installer can do it for you most of the cases); verify it's done by opening cmd.exe and typing gcc -v and mingw32-make -v, both should give you half a screenful of version information if your path is set correctly,
via cmd.exe, navigate to the folder in which the Makefile resides and call mingw32-make.
From now on everything should compile automatically. If it doesn't, post the errors.
Update:
First of all, it'd be useful for you to get the MSys package. Install it and you'll have a more recent version of make (use it instead of mingw32-make from now on).
About the CreateProcess bug, it has to do with the system PATH variable being too long. You'd need to do something like this:
open cmd
execute set PATH=c:/mingw32/bin;c:/msys/1.0/bin (change the paths here to reflect your own installation if it's different)
then as before: navigate to your project's directory, run make. Everything should be smooth now if you're not missing any external libraries.
BTW- remember not to install MinGW or MSys in directories with spaces.
I am not a Windows Developer..
But still as per my knowledge. Visual Studio (i.e 2008, I guess) has the ability to read the Makefile.
Please have a look at it..and if needed change this makefile to their format..
There are many opensource product which are platform independent..and they get compiled on both OS with the just Makefile they provided.
Or else use 'cygwin'
Developer C++ works in windows but it is actually GCC code bought into Windows, Is anyone familiar about the procedure they used to convert the linux ( .sh) to executables ??
I think i need to download compilers for C or some sdks right?
A compiler certainly, but what additional libraries you may need will depend entirely on the code itself. A successful build may also depend on the intended target of the original code and makefile. The makefile may be a GNU makefile, but there are other similar but incompatible make utilities such as Borland Make and MS NMake. If it is a simple build, you may be able to avoid the makefile issue altogether and use the project management provided by an IDE such as Visual C++ 2010 Express.
If you do not know what this code is or what it does and what it needs to build, you are taking a risk building it at all. Maybe you should post a link to the original source so that you can get more specific advice on how to build it.
[EDIT]
Ok, now looking at the code you are attempting to build, it is a very simple build, so if you wanted to avoid using GNU make, then you could just add all the *.c files in the src folder to a project in your IDE and build it.
However there is one serious gotcha, it uses the BSD sockets API and Linux system headers. You will need to first port the code to Windows APIs such as WinSock (very similar to BSD Sockets), or build it under Cygwin (a sledgehammer for a nut somewhat). There may be other Linux dependencies that need sorting, I have not looked in detail, but it looks fairly simple. That said, if you did not have the first clue regarding compiling this stuff, then perhaps this is not a task you could do?
Of course compiling the code may only be half teh problem, if it was designed to run on Linux, there may be run-time dependencies that prevent it running on Windows. Again I have not looked in detail.
Also looking at the code, I would suggest some caution, this may not be the best quality code. That may be unfair, but one obvious flaw and an indication if inexperience is the lack of include guards in the headers.

Resources