Author Topic: select a host application to "run"  (Read 7417 times)

Offline J4e8a16n

  • Single posting newcomer
  • *
  • Posts: 5
select a host application to "run"
« on: April 28, 2009, 03:10:53 pm »
Hi,

I red dozens of post on that matter and I am still lost. They talk about debuggers , C++ , etc.
Is Code Block an Ide? Are the examples not suppose to work by themselves?

I am learning C.

Here is my example I took on :  http://melem.developpez.com/langagec/objc/

CodeBlock produces dsomme.o and exemple.o
Code: [Select]
------- dsomme.c----
__declspec(dllexport) int somme(int a, int b)
{
    return a + b;
}

__declspec(dllexport) int produit(int a, int b)
{
    int prod = 0;

    while (b-- > 0)
        prod += a;

    return prod;
}
---------------------------------

--------- exemple.c   --------
#include <stdio.h>

__declspec(dllimport) int somme(int a, int b);
__declspec(dllimport) int produit(int a, int b);

int main(void)
{
    int a = 2, b = 5;

    printf("%d + %d = %d\n", a, b, somme(a, b));
    printf("%d * %d = %d\n", a, b, produit(a, b));

    return 0;
}
---------------------------------------

Compiler is gnu gcc 4.4.5

-------
HP Pavilion Elite m9525f Desktop PC
Vista Édition Familiale Premium SP1  64 bits
Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz
Intel 64 (EM64T), x86-64
------------

Thanks for your attention,

JPD

[attachment deleted by admin]
« Last Edit: April 28, 2009, 03:12:28 pm by J4e8a16n »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9612
Re: select a host application to "run"
« Reply #1 on: April 28, 2009, 03:30:58 pm »
Thanks for your attention,
Mind asking a question? What is your problem?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline J4e8a16n

  • Single posting newcomer
  • *
  • Posts: 5
Re: select a host application to "run"
« Reply #2 on: April 28, 2009, 04:46:11 pm »
:o)
You seem to be in the same state has me when I red "select a host application to "run" ".

So. What does mean select a host application to "run" ?

JPD

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9612
Re: select a host application to "run"
« Reply #3 on: April 28, 2009, 08:02:07 pm »
So. What does mean select a host application to "run" ?
It means that you cannot run a DLL as an application. It's a Dynamic Link Library. Libraries are loaded by a host application. Thus you need to run the host application to load/run the library functions.

As an example: You need to run codeblocks.exe to load the plugins (*.DLL's). For the plugin DLL's of Code::Blocks there is codeblocks.exe setup as "host application to run" therefore.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline J4e8a16n

  • Single posting newcomer
  • *
  • Posts: 5
Re: select a host application to "run"
« Reply #4 on: April 28, 2009, 09:12:58 pm »
exemple.c compiled as exemple.o has main function.
If it is compiled by code block can that be the host application?



Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9612
Re: select a host application to "run"
« Reply #5 on: April 28, 2009, 09:29:15 pm »
exemple.c compiled as exemple.o has main function.
If it is compiled by code block can that be the host application?
No, because *you* told C::B in the project options to create a DLL. Thus the main function is a function of your DLL (although this is weired).

You have these options now:
1.) Change your project to produce an application
2.) Add another target -> use one target for the DLL generation, use he other for the (host) application generation.

However - this goes beyond the scope of C::B anyways so we start violating our forum rules. I suggest strongly you read yourself into library programming and how the "DLL mechanism" actually works. Hence this is not related to C::B.

Edit: Although I don't understand a single word french I believe the answer to you question is on the page you are referring to in your post in the section "II-C. Les bibliothèques dynamiques". dsomme.c will be the DLL and exemple.c the host application. So you need two projects (or one project with two targets alternatively)! Please read your article again.
« Last Edit: April 28, 2009, 09:35:53 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline J4e8a16n

  • Single posting newcomer
  • *
  • Posts: 5
Re: select a host application to "run"
« Reply #6 on: April 28, 2009, 09:51:09 pm »
I already did sucessfully three projects with dlls using the compiler directly. One static and two dynamic dlls with success at http://www.cygwin.com/cygwin-ug-net/dll.html#dll-build

So I told to myself, 'now lets see if it would be automatic with C::B'. It does not seem so.

C::B creates the o files but dont relate (linK) them.  I doubt it  is not related to C::B  but you are the boss on that matter and I dont want to wear your avatar.


Well that's ok.

Have a good day.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9612
Re: select a host application to "run"
« Reply #7 on: April 28, 2009, 09:54:19 pm »
So I told to myself, 'now lets see if it would be automatic with C::B'.
See: This cannot be done automatically without taking the risk of making errors. The correct project setup has to be done by the developer.

I doubt it  is not related to C::B [...]
Well - if you were right we would not be able to build C::B using C::B (as C::B uses DLL's as plugins)... right? But we do... so...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline J4e8a16n

  • Single posting newcomer
  • *
  • Posts: 5
Re: select a host application to "run"
« Reply #8 on: April 28, 2009, 10:08:44 pm »
Quote
See: This cannot be done automatically without taking the risk of making errors. The correct project setup has to be done by the developer.
Yes.

That's ok.

Usually, they (creator) is an ultra basic project showing how to do that kind of project and then they  (visualC++, etc)  let the user develop complex things by themselves.

We, the users, read the automatically generated makefile, etc, and learn from that. We dont learn C.

We dont learn how to make C with learn how to use the user interface.

It is only my 2 cents.