I'm trying to generate spotify playlists (not text-based) and found this on Github: https://github.com/liesen/spotify-api-server
I have no experience in C programming so i don't really know where to start. Are there any relevant tutorials/articles on setting up a c-server similar to the one i'm trying to set up? on a pretty basic level.
I have a sneaking suspicion that building and using this C program isn't actually what you want (http://developer.spotify.com/en/spotify-apps-api/overview/ might be easier for you to get started with), but I'm going to help you anyway.
Most C projects have a README file that tells you how to build them. In this case, it says:
Make sure you have the required libraries
libspotify > 9
subversion (libsvn-dev) and its dependency, libapr
libevent >= 2.0
jansson >= 2.0
Update account.c with your credentials. A Spotify premium account is necessary.
Copy appkey.c into the directory and run make.
There are a few extra things that the README doesn't say, that an experienced developer will be able to guess at:
libsvn-dev and libapr are the names of Ubuntu packages (I think), so it is probably expecting your development machine to be running Ubuntu. You should probably install build-essentials as well (on a new machine, I would usually run apt-get install ${*-dev-packagages} and then apt-get build-dep ${*-dev-packages}. build-dep might download some packages that you don't need, but bandwidth is cheap, and debugging missing packages is a pain in the ass.
when it says libspotify > 9 it normally means "greater than 9 but less than 10" (if the first number in a C-library version number changes, it normally means "BEWARE: we broke things."). If you get build errors about wrong number of arguments to functions, this is probably why.
It says "run make" so there will be a file called Makefile somewhere. You need to cd into the directory that contains Makefile before typing make
make will probably produce an executable file somewhere. I usually find these by running ls and looking for items highlighted in green. If I can't find anything that way, I will read Makefile and note that "all" depends on "server" so I would look for an executable called "server".
You are jumping in at the deep end here (building someone else's experimental package as your first C program). If you get errors that you don't understand, it's not because you're stupid: it's because C is a brutal and archaic language, and it wasn't designed as a teaching language like Python was, or a beginner-friendly language like Javascript. Once you get used to it, you start to see steamtrain-like beauty of the language; the pain subsides to a dull ache, but it never truly goes away.
Related
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.
Apologies if I explain this badly or am asking something bleeding obvious but I'm new to the Linux kernel and kinda in at the deep end...
We have an embedded-linux system which arrives with a (very badly documented) SDK containing hundreds of folders of stuff, most folders containing a rules.make, make, make.config or some variation of... and the root folder containing a "master" makefile & rules.make which mean that you can, from the root folder, type "make sysall" and it builds the entire package.
So far so good, but trying to debug it is a bit of an issue as the documentation will say something like:
"To get the kernel to output debug messages, just define #outputdebugmessagesplz"
OK, but some of these things are defined in the "master" make/rules file, some of these are defined in the child make/rules/config files, some are in .h files... and of course it's far nicer to turn these things on/off from the "top" make.config rather than modifying individual .h files and then having to remember to turn them off again.
So I thought it would be a useful thing to recursively build a tree, starting from the master "make" file and following everything it does, everything that gets defined or re-defined, etc... but there doesn't seem to be a simple way of doing that?
I assume I am missing a "make" option here that spits this info out, or a usage of the makefile/config that will just work?
Your situation is not uncommon. When developing for embedded systems, you might encounter many custom systems that solve a problem in a specific way. As people already commented on your question, there's no easy way to generate a dependency graph for your makefile structure/framework. But there are some things you can try, and I'll try to base my suggestions based on your situation. Since you've said:
Im new to the Linux kernel and kinda in at the deep end...
and
We have an embedded-linux system which arrives with a (very badly
documented) SDK containing hundreds of folders of stuff
You could try the following things:
If your SDK is provided by a third-party vendor, try contacting them and get some support.
SDK's usually provide an abstraction to work with several components without a deep understanding of how each one of them really works. Try to pinpoint your problem, like if you want to customize only the kernel configuration, you could find the linux kernel folder on your SDK (assuming your SDK is composed of a set of folders with things like libraries, source code of applications and stuff, one of them might be the kernel one) and run make menuconfig. This will open a ncurses-based configuration GUI that you can navigate and choose kernel options.
As people already pointed out, you can try to run make -n and check the output. You could also try to run make -p | less and inspect the output, but I don't recommend this since it will only print the data base (rules and variable values) that results from reading the makefiles. You would have to parse this output to find out what you want in it.
Basically, you should try to pinpoint what you want to customize and see how this interacts with your SDK. If it's the kernel, then working only with it will give you a starting point. The linux kernel has its own makefile-build system, named kbuild. You can find more information about it at the kernel's Documentation folder.
Besides that, trying to understand how makefiles work will help you if you have a complex makefile structure controlling several components. The following are good resources to learn about makefiles:
GNU Make official documentation
O'Reilly's Open Book "Managing Projects with GNU Make"
Also, before trying to build your own tool, you can check if there's an open source project that does what you want. A quick search on google gave me this:
makegrapher
Also, check this question and this one. You might find useful information from people that had the same problems as you did.
Hope it helps!
I have been trying to compile open source projects since past few months with no success. I just don't know how to go about the entire thing. Readings over the internet have not helped much.
Some come with ./Configure and a Makefile while others with only a Makefile. How to use them to generate executables (or they have some other purpose ).
My machine currently has:
Windows XP,
Mingw Compiler for C/C++,
Cygwin
Do I need any other software?
Thanks!
Edit:
Thanks for the response. Currently I am trying to compile "Null Httpd". It comes only with a makefile.
In my command line prompt I type
/directoryContainingMakeFile/mingw32-make Makefile
I get
"Nothing to be done for 'Makefile'"
:(? Am I doing it the right way?
./configure is the first thing to run, if it exists -- it checks if your system has the requirements for the project, and also allows you to set project specific settings or simply set the default values.
Next, the command make (though some projects require automake, or cmake, which are similar but more powerful utilities) takes those configurations and builds from the source code into the executable. Make isn't a compiler in itself though -- its simply used to specify how to build the project. Most projects in C use gcc, probably with many standard libraries to be linked in, in which case this should run on top of cygwin perfectly well. If it has other dependencies however, you are on your own for the most part (this gets complicated very quickly -- if this happens, its usually a less time-consuming effort to work in the OS the source was made to compile on).
After this, you should find the binaries you require in the same directory :)
I'm building something that installs a high-level stack, and to do that, I need to install the lower-level stuff.
The simplest way to look for whether, say, Java is installed, is to just shell out a which java in a shell script and check if it can find it. I'm now to the point where I need to do some libraries without an obvious binary- basically stuff that is an include from within C. libxml, for example.
I'm woefully green to C in general, so this makes things a little tricky for me. :) Ideally I could just make a shell script that calls a little C applicaiton that calls #include <xxxx>, where xxxx is the library that I'm checking the existence of. If it can't find it, it errors out. Unfortunately, of course, all that happens prior to compilation, so it's not as dynamic as I'd like.
I'm doing this on a system that probably doesn't have anything installed on it (be it high-level language or package managers or what have you), so I'm looking more for a basic shell script way of doing things (or maybe some clever C or command-line gcc options). Or maybe just manually search the include paths that gcc would look for anyway /usr/local/include, /usr/include, etc.). Any thoughts?
Autotools is really what you need. Its a huge (and bizarre) framework for dealing with this very problem:
http://www.gnu.org/software/autoconf/
You can also use pkg-config, which will work with newer software making use of that mechanism:
http://pkg-config.freedesktop.org/wiki/
this is the purpose of configure (part of automake and autoconf)
i have a unix c programming assignment in which i do some advanced C network programming.this is my first step into advance programming. so i was wondering what is the best combination of tools for this on a mac. using an IDE like Eclipse is how i'd normally do it but i have to make my own makefiles and stuff. so i would like to learn how it can be done effectively using may be emacs or vim + other tools. it will be quite a big project so i am worried about project management and debugging issues mostly as well as the productivity factor. in essence i want to learn how programmers do it in the professional environment without the bloated IDE part. i am using Snow Leopard.i would also delve into C++ and python in the future so may be something that will be useful for those as well.
I know you're asking for how to do it with makefiles/VI/etc. but on the Mac, Xcode is really the way to go, especially for large projects. It's a very effective wrapper that will call gcc and gdb and the linker for you. Especially when moving to a new platform, not having to worry with many of the pesky details will be a big leap in productivity. It's IDE debugger is quite awesome.
Of course you can also use makefiles etc. Many projects (just to take OpenSSL as an example) come with makefiles and you can compile them on the Mac from the commandline just like under the *ix operating systems, i.e. calling ./configure and then make. But setting up stuff like that (e.g. compiler options for universal binaries and such) is tedious while the IDE it's just a few options. Also, if you google for specific questions, you will find far more answers on how to do it with Xcode.
If you want to get started with Xcode, it's either on your Mac operating system CD (it just does not pre-install automatically) or you can download it from Apple. When you run it, just open a Mac OS X Project of type "Application - Commandline Tool" and you'll have a project with a main.c set up in a minute. You can then just run it or run it in the debugger like that and adding more source files to it is rather easy.
Xcode can be quite a beast for setting up an already large project (we ported a large project with DLLs and depending exes (overall 250000 lines of code) to the Mac and just getting that all set up wasn't what you call a piece of cake) but if you start from scratch you'll easily grow into it.
Bottom line is that Xcode certainly is equipped to deal with large projects and I can not imagine a more productive way of doing it (I have used hand written makefiles and such in the past so I know both worlds).
Xcode is your friend. It's free and is a very nice IDE. When you launch XCode, just start a new Console application (it'll be ANSI C).
Enjoy.
If learning the rudiments of unix editors, shell programming, make, etc., are part of the assignment, then you just need to dive in and learn what you need to learn. Some good books will help. Obviously you need K&R. I always liked the O'Reilly books for Unix stuff, usually because they are the thinnest. I hate thick computer books because they never get read. You should also learn how to use the man pages.
Vim vs. Emacs is a religious choice. If you ask any Unix guy what is the best, he will invariably tell you the one he learned first, because chances are he never learned the other. In my case, I've been using Vim so long that my escape key is worn out and the commands are hard-wired into my brain. Obviously, I think it's way better than emacs (which I never learned!) If you are lucky enough to have a Mac as a work station, install mac vim. It's great.
Make is complicated enough so that you will never really master it. Just learn enough to compile and link your program. You can always learn more if you need it.
Version control is an interesting question... I use RCS for small stuff. Like vi, it is on every Unix machine. For really big projects, I use subversion, but like editors, most people use whatever they learned first. Git people will say its the only one to use, etc.
Command line debuggers are a pain, which is a main selling point for Xcode. I've used gdb, but I don't remember it as a pleasant experience. Its been so long since I used it, I can't even remember how to start it up. There must be better debuggers by now. Try google.
Bottom line, all the things you mentioned are big topics. You need to take realistic bites of each and not get tangled in the weeds. It can take years to master them all.
Finally, I'd stay as far away from C++ as possible! Objective C is much better. Personal prejudice!