How do I create a library in dev-c? I created the following files in c:
// utils.h
extern int parImpar(int n);
//utils.c
include "utils.h"
int parImpar(int n)
{
if (n%2==0)
return (1); / Numero é par/
else
return (0); // Numero é par
}
//prin.c
include "utils.h"
include <stdio.h>
include <stdlib.h>
int main()
{
int b;
printf("\n\n\tIndique um numero: ");
scanf("%d",&b);
if (parImpar(b) == 1)
printf("\n\n\n\tO numero e par\n\n\n\n\n");
else
printf("\n\n\n\tO numero e impar\n\n\n\n\n");
system("pause");
return(0);
}
But when I compile the console project I obtain the error "[Build Error][utils.o] Error 1".
Can you help me to resolve this error?
thanks
Lya
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) What makes you think you need to create a library?
2) Libraries should not normally contain a main() function unless you are building an application framework perhaps.
3) What would be the point of a library containing just one function in any case?
4) The so called error you posted merely indicates that the build failed. The reason for failure will be indicated by the Compile Log which is what you should have posted.
What I suspect you really want to do is simply create a single executable form multiple source files. For that each source must be separately compiled and then linked. Fortunately Dev-C++ will manage this for you by creating a 'project' to manage your build. File->New->Project. Once you have created your project, you can configure it and add sources via the "Project" menu.
Incidentally if you really did want to create a library you do it the same way, (i.e. File->New->Project)
Is it just me that thinks that this is blindingly obvious and anyone with sufficient curiosity to have explored the Dev-C++ menus and dialogs would have figured this out for themselves? ... Probably just me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How do I create a library in dev-c? I created the following files in c:
// utils.h
extern int parImpar(int n);
//utils.c
include "utils.h"
int parImpar(int n)
{
if (n%2==0)
return (1); / Numero é par/
else
return (0); // Numero é par
}
//prin.c
include "utils.h"
include <stdio.h>
include <stdlib.h>
int main()
{
int b;
printf("\n\n\tIndique um numero: ");
scanf("%d",&b);
}
But when I compile the console project I obtain the error "[Build Error] [utils.o] Error 1".
Can you help me to resolve this error?
thanks
Lya
1) What makes you think you need to create a library?
2) Libraries should not normally contain a main() function unless you are building an application framework perhaps.
3) What would be the point of a library containing just one function in any case?
4) The so called error you posted merely indicates that the build failed. The reason for failure will be indicated by the Compile Log which is what you should have posted.
What I suspect you really want to do is simply create a single executable form multiple source files. For that each source must be separately compiled and then linked. Fortunately Dev-C++ will manage this for you by creating a 'project' to manage your build. File->New->Project. Once you have created your project, you can configure it and add sources via the "Project" menu.
Incidentally if you really did want to create a library you do it the same way, (i.e. File->New->Project)
Is it just me that thinks that this is blindingly obvious and anyone with sufficient curiosity to have explored the Dev-C++ menus and dialogs would have figured this out for themselves? ... Probably just me.