Open Side Menu Go to the Top
Register
Lots of questions about building, compiling and reading C source codes from other people. Lots of questions about building, compiling and reading C source codes from other people.

08-28-2014 , 02:19 PM
Be warned, I have a lot of questions, and I appreciate any attempt to help me.
To my understanding a library should be designed to be used without requiring information about the implementation.
Let's take a look at:
https://github.com/v2k/poker-eval

I want to use 1 function from this library. Say I want to compile it.
Do libraries require the user to be knowledgeable of the implementation used in order to compile it? Do libraries require the user to be knowledgeable of every compilation technique in use to be able to compile it? If the answer is no, does this library in particular fail to meet those requirements and requires a greater knowledge of the implementation for me to actually use it?

On another note, do library usually require more documentation than this? Or is this library as readable an understandable as I can expect?
I started reading the library from the "eval.c" in the examples folder.
https://github.com/v2k/poker-eval/bl...xamples/eval.c
In the first line only I had to go through 3 files in order to find out what HandVal was. I feel that at this pace, if I want to understand a simple example program, I am going to have to go through all of the files.

On the other hand there's this chess program.
http://www.craftychess.com/crafty-23.4.zip

Which although I still have difficulty reading, it's well documented and I can skip the parts I don't understand. And obviously, if I could compile it I could use it, but I can't use the functions because they are not designed to be used without knowing the implementation details.
But I still couldn't compile this one. Probably because it is designed to be compiled with the makefile.
Since the source code is completely dependent on macros set by the makefile, I am assuming it shouldn't be attempted to compile without the makefile. If that is so, how can I compile it in windows? I have never been able to run a makefile (or any source code not created by me). Are makes solely to be used by their compilers? Or are they usable by other compilers? Can I compile this with Vc++ express, pelles C, mingw or cygwin?(Yep, I tried them all.)

In an attempt to reduce the number of questions here are the main four.
I can't compile the first library. Are all libraries this hard to compile?
It's very hard to read this library. Are all libraries this hard to read?

I can't compile the chess program. How is this program designed to be compiled and by what compilers?
This program is pretty hard to read.How is this program designed to be read? What is a good IDE where I can, say, click on a function, typedef, define. And the program will direct me to the definition of said element? (Or is this feature not needed to read the program easily?)

Thanks a lot. This has been one of my big barriers in learning to code for years, I am basically restricted to the C's ISO standard libraries and my own functions and programs.

Last edited by LoveThee; 08-28-2014 at 02:33 PM.
Lots of questions about building, compiling and reading C source codes from other people. Quote
08-28-2014 , 04:53 PM
re: compilation, it appears to use the very standard configure/make tools that are popular on linux and other UNIXy OSes. It seems likely given the tools you reference that you are trying to build it on windows. It's often a bit more difficult to get that to work because the original authors include windows support as an afterthought.

the readme covers how to get it to build using Visual C++ but specifies that it may be out of date. You'll need to have the DOS equivalent make tools (nmake) installed and paths setup. the readme doesn't cover all this and I haven't really ever done it, but that's the challenge. It would be easier on linux.

As far as understanding how to use it, the examples are your best bet. I think how hard a library is to use is going to vary a lot from project to project. Lots of open source projects probably have thin documentation. Chalk it up to programmers gonna program.

Crafty also has a makefile so something like nmake on windows is going to be your best bet, or maybe cygwin. Again, unix is going to be easier. It's not a library so using functions out of it is always going to involve figuring out how to extract all the things you need to make the functions work. This is always going to be more challenging then consuming a library API.
Lots of questions about building, compiling and reading C source codes from other people. Quote
08-29-2014 , 12:24 AM
Quote:
Originally Posted by LoveThee
.....But I still couldn't compile this one. Probably because it is designed to be compiled with the makefile.
Since the source code is completely dependent on macros set by the makefile, I am assuming it shouldn't be attempted to compile without the makefile.......
If you are referring to C macros this is just wrong. You probably don't have your compiler settings such that it is looking for your include files in the right directory. Post a specific example of one such issue you are having and the compiler you are using and we'll help you get through it. I'm the most familiar with VS and gcc.
Lots of questions about building, compiling and reading C source codes from other people. Quote
08-31-2014 , 10:20 PM
Quote:
Originally Posted by well named
re: compilation, it appears to use the very standard configure/make tools that are popular on linux and other UNIXy OSes. It seems likely given the tools you reference that you are trying to build it on windows. It's often a bit more difficult to get that to work because the original authors include windows support as an afterthought.

the readme covers how to get it to build using Visual C++ but specifies that it may be out of date. You'll need to have the DOS equivalent make tools (nmake) installed and paths setup. the readme doesn't cover all this and I haven't really ever done it, but that's the challenge. It would be easier on linux.

As far as understanding how to use it, the examples are your best bet. I think how hard a library is to use is going to vary a lot from project to project. Lots of open source projects probably have thin documentation. Chalk it up to programmers gonna program.

Crafty also has a makefile so something like nmake on windows is going to be your best bet, or maybe cygwin. Again, unix is going to be easier. It's not a library so using functions out of it is always going to involve figuring out how to extract all the things you need to make the functions work. This is always going to be more challenging then consuming a library API.
Thanks, I feel relieved to know that it's probably easier on Linux. I'll try that.
Nmake is a good idea.

Quote:
Originally Posted by adios
If you are referring to C macros this is just wrong. You probably don't have your compiler settings such that it is looking for your include files in the right directory. Post a specific example of one such issue you are having and the compiler you are using and we'll help you get through it. I'm the most familiar with VS and gcc.
One such example of a problem was that when trying to compile on an IDE it would build for linux.(And wouldn't find linux only include files like pwd.h.

I tried using nmake from the command line and it seems to work!
But, yep, it can't find the header for stdio . Where does the VS compiler look for them? Also, does nmake call cl.exe to compile?
Thanks.
Lots of questions about building, compiling and reading C source codes from other people. Quote
08-31-2014 , 11:01 PM
I don't know if cl.exe is the compiler or linker or both or what, but apparently it has something to do with compiling in VC++

The readme for the poker-eval lib mentions a vcvars32.bat, which you might look for under the install for VC++. I expect running it in a shell before you run nmake will fix up the environment variables you need to get nmake to figure out where to look for standard header files and libraries and so on. Depending on the version this may also be useful: http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx
Lots of questions about building, compiling and reading C source codes from other people. Quote
08-31-2014 , 11:13 PM
Quote:
Originally Posted by LoveThee
Thanks, I feel relieved to know that it's probably easier on Linux. I'll try that.

Nmake is a good idea.





One such example of a problem was that when trying to compile on an IDE it would build for linux.(And wouldn't find linux only include files like pwd.h.



I tried using nmake from the command line and it seems to work!

But, yep, it can't find the header for stdio . Where does the VS compiler look for them? Also, does nmake call cl.exe to compile?

Thanks.

I am on my iPad so off the top of my head right click on solution explorer window and select properties. You should see a place for the include file directories. I'll try and look later to confirm. You can do a search in the vs folders for stdio.h. It is absolutely incredible how unfriendly VS is to C/C++ development sometimes at least in my view it is.

Last edited by adios; 08-31-2014 at 11:21 PM.
Lots of questions about building, compiling and reading C source codes from other people. Quote

      
m