Author Topic: problem in compiling an application source file with C:B  (Read 12395 times)

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
problem in compiling an application source file with C:B
« on: August 26, 2008, 09:30:32 am »
hi,
I want to use code blocks for compiling source of an applicaion .... (.tar file)
I have started a new project>console application and
according to the make file , I added the needed .c files and also I have added defines and libraries to the project build options (in both Debug and Release mode)....... but C::B cannot compile it ...why? where is the problem?  :?:
thanks

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #1 on: August 26, 2008, 10:47:01 am »
remove make file

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #2 on: August 26, 2008, 11:27:54 am »
I think  there is a misunderstanding....
I didn`t use  the make file...I just look at it to see which files are necessary for compile and making executable file

and then I added the necessary files to a new project in code::blocks.....

I also set the libraries and defines in build option...
but I don`t know what`s the problem

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #3 on: August 26, 2008, 12:36:45 pm »
what error?

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #4 on: August 26, 2008, 12:47:34 pm »
there is no error ....but its output in the Debug folder is and executable file that can`t run correctly ...the error is: segmentation fault
and there is nothing in release...it seems it can compile the file but cann`t build...........

I`m sure that the source file has no problem ....I have once compile it using its make file

but I`m not sure that whether it`s the correct way to compile source of an application or not... and what`s the correct way?
« Last Edit: August 26, 2008, 12:59:20 pm by parisa_k »

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #5 on: August 26, 2008, 08:01:28 pm »
run application with valgrind. Example: valgrind ./bla-bla
and see what problem, which string in source code.

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #6 on: August 27, 2008, 07:31:30 am »
here I exactly explaind my problem::


I have uploaded the sorce file here (it`s iozone (a filesystem benchmark) source code with some changes....

http://rapidshare.com/files/140436058/ii.tgz.html

you can make its executable file by using this command it terminal (in files path)
make linux
then you see it runs  correctly....
--------------------
but now I want to do the same thing with C::B
I start a new project> console application
then I add the source files to it ....and set defines and libraries (by looking at make file) to it ....

libraries: pthread , rt
defines:
NAME = "linux"
unix
linux
HAVE_ANSIC_C
ASYNC_IO
_LARGEFILE64_SOURCE
SHARED_MEM
HAVE_PREAD


I expect that when I run this project, the executable file become created....
but it doesn`t happen (perhaps because of some problems)...I want to know what is the problem and how to solve it (maybe the problem is with the way that I used)
I would be thankful if anyone can help
thanks
« Last Edit: August 27, 2008, 07:34:42 am by parisa_k »

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #7 on: August 27, 2008, 09:03:45 am »
how you call functions from "main" function.

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #8 on: August 27, 2008, 09:19:45 am »
I just added the .c files to the project and then run it ... no change in main.c....does it need to be called and how?
does it solve the problem?

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #9 on: August 27, 2008, 09:26:05 am »
I also removed the main.c from the project ...I think it can find the main() in iozone.c and will use it as the main function

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #10 on: August 27, 2008, 11:03:56 am »
i think you need create empty project and add all files.

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #11 on: August 27, 2008, 11:13:03 am »
that`s exactly what I did but it couldn`t run successfully ...is it possible for you to test the code yourself
« Last Edit: August 27, 2008, 11:18:58 am by parisa_k »

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #12 on: August 27, 2008, 01:29:08 pm »
i'm create empty project and add all files, but can't build project. I see many erros, for example: conflict types. I don't know what this should be working. I think problem with download files, but i can make mistakes.

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #13 on: August 27, 2008, 01:38:45 pm »
but it didn`t have any errors when I run it.....
the source file is correct because you can compile it using make file ....and after that the application can be run successfully.....
make linux
so it seems that C::B also should be able to run it ...but it cannot ...


but about the errors that you saw:

did you remove the main.c file.....
and did you add defines and libraries to build options..........
(Reply #6)


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: problem in compiling an application source file with C:B
« Reply #14 on: August 27, 2008, 02:43:42 pm »
The first point is that this question is not really C::B related.

The second is that the code compiles with tons of warnings and is not really readable.

The third is that compiling it with C::B is quiet easy if you use the makefile, otherwise it needs some more tweaking.

And the fourth and most important is that you posted the link to the code just 6 hours ago and if nobody has answered your question in a way that it works for you means that nobody has an idea how to do that, or nobody wants to do your homework.

There is no cause to be impatient.


Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #15 on: August 27, 2008, 02:53:29 pm »
i'm not create main.c and yes i added libraries.

please send me you project. mczimm@gmail.com

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #16 on: August 27, 2008, 03:13:27 pm »
I sent it .... if you could find the solution please tell me... I expect that after compiling a correct executable file become created in bin>debug
the current one is not correct if you run it it gives segmentation fault

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: problem in compiling an application source file with C:B
« Reply #17 on: August 27, 2008, 03:45:32 pm »
i'm compile you project and see error in the string:

Code
char *build_name = NAME;

Code
/home/mczim/main/trash/iozone_benchmark/iozone/iozone.c|1237|error: initialization makes pointer from integer without a cast|
« Last Edit: August 27, 2008, 03:53:41 pm by McZim »

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #18 on: August 30, 2008, 08:12:37 am »
thanks for your help...but I really don`t know how could this happen ... when I run it, gives no error...

but anyway ....this error that you said, shows that NAME is not defined....

please go to build option, Debug ..and in #defines tab check whether defines are correctly set ...if they are not set, set them and build&run the project again.........
NAME="linux"
unix
linux
HAVE_ANSIC_C
ASYNC_IO
_LARGEFILE64_SOURCE
SHARED_MEM
HAVE_PREAD

another thing is that you may seen that it compiles using make file (if not, you can check it now)....so it shows that the code has no problem ...the question is that how to compile it using code blocks.................

this is the source of IOZone Filesystem Benchmark  :www.iozone.org
ofcourse the benchmark source is correct and has no problem .............maybe I have to set some other options in code blocks to compile it...I want to know what are they????
   
maybe you have another way to compile this source code in C::B...what is your suggestion???
thanks

Offline parisa_k

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: problem in compiling an application source file with C:B
« Reply #19 on: August 30, 2008, 08:57:05 am »
The first point is that this question is not really C::B related.
of course this problem is directly related to C::B because the source code is surely correct and I have tested it before (it`s the source code of IOZone Filesystem Benchmark)
The second is that the code compiles with tons of warnings and is not really readable.
as I said the code has no errors ...but if you see any errors you can report it to IOZone working team (www.iozone.org)...they would be thankful because till now no one could see any errors in this code
The third is that compiling it with C::B is quiet easy if you use the makefile, otherwise it needs some more tweaking.
maybe it`s easy for you, but I have spent a lot of time but I couldn`t solve the problem yet ...if you could explain your easy solution for me, I would be really thankful
And the fourth and most important is that you posted the link to the code just 6 hours ago and if nobody has answered your question in a way that it works for you means that nobody has an idea how to do that, or nobody wants to do your homework.
First it`s not a homework or sth like that ,...I `m just trying to learn how to use C::B and also I `d like to know about C::B specifications, to see whether it `s suitable for my need  as a C IDE or not
Second I think the best way to solve this  problem is to ask for others solutions here, If you have any other suggestion, I`d be thankful if it could help

And the third and most important is that, if you don`t have any answer  for my posts, it doesn`t need to post such a thing....I accept that I`m new to C::B and this question is really a basic (and perhaps simple) but I expect the others to help me not to tease ....
« Last Edit: August 30, 2008, 09:06:44 am by parisa_k »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: problem in compiling an application source file with C:B
« Reply #20 on: August 30, 2008, 11:08:54 am »
I `m just trying to learn how to use C::B and also I `d like to know about C::B specifications, to see whether it `s suitable for my need  as a C IDE or not

If you want to see if C::B fits for your needs you should at first understand how it works.

And converting a makefile project is not the best way to understand C::B's build system.

I think the best way is always to use it for a typicall C::B-project (that means use the wizard and see what it creates).

Reading the manual and the wiki might also be helpful.

And it's not really C::B related to port a project to C::B, because there are too many different projects out in the world and it's beyond the task of this forum to help to port them all.

The second is that the code compiles with tons of warnings and is not really readable.
as I said the code has no errors ...but if you see any errors you can report it to IOZone working team (www.iozone.org)...they would be thankful because till now no one could see any errors in this code

I did not say anything about errors, but warnings, and that's a difference. But why do you blame the IOZone team if you create such a crippled package for download and don't tell anybody that you cut away the most cpu and platform related parts (your makefile has 708 Bytes the original one is more than 45 KBytes). I tried to compile on a 64-bit system and that leads of course to many warnings if the code and/or the compile-flags and -defs are platform-specific.

And my tip was: use the makefile.
To be more specific: use it as custom makefile, a really port of this project to C::B can surely be a good execise, but I'm not sure if it really makes sense.
But if you really want it, no problem.

But before you ask (and the first of your posts did not include any relevant information) please read and understand the documentation and provide as many information about the problem as possible.

That's my last post in this thread as I spent much too much of my time for this thing.