473,467 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Error while trying to make library in code blocks

57 New Member
Hi

I tried to make a library using code blocks. For which I went file->new->project->static library and name it as mylib and then i created a file mylib1.c and mylib1.h (with some sample functions in it like Swap) and build them. Now I again make another project hello in which i make a file main.c in which I included lib1.h. When i tried to run the program i got the message "please select the host to run the library" something like that. Then i google it and then i went to project->build options->linker setting and then i add ..\mylib\libmylib.a. After that i got the error

lib1.h-No such file or directory.

What should i do?

Here is the code

For library

lib1.c
Expand|Select|Wrap|Line Numbers
  1. // The functions contained in this file are pretty dummy
  2. // and are included only as a placeholder. Nevertheless,
  3. // they *will* get included in the static library if you
  4. // don't remove them :)
  5. //
  6. // Obviously, you 'll have to write yourself the super-duper
  7. // functions to include in the resulting library...
  8. // Also, it's not necessary to write every function in this file.
  9. // Feel free to add more files in this project. They will be
  10. // included in the resulting library.
  11.  
  12. // A function adding two integers and returning the result
  13. int SampleAddInt(int i1, int i2)
  14. {
  15.     return i1 + i2;
  16. }
  17.  
  18. // A function doing nothing ;)
  19. void Swap(int *a , int *b)
  20. {
  21.     *a=*a+*b;
  22.     *b=*a-*b;
  23.     *a=*a-*b;
  24. }
  25.  
  26. // A function always returning zero
  27. int Increa(int x)
  28. {
  29.     return ++x;
  30.  
  31.     return 0;
  32. }
  33.  
lib1.h

Expand|Select|Wrap|Line Numbers
  1. void Swap(int *a , int *b);
  2. int Increa(int x);
  3. int SampleAddInt(int i1, int i2);
  4.  
Then another project Hello i made main.c
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include"lib1.h"
  4. int main()
  5. {
  6.     int a=1,b=2;
  7.     Swap(&a,&b);
  8.     printf("%d  %d",a,b);
  9.     return 0;
  10. }
  11.  

What should i do?I am using codeblocks with mingw under windows?

I have attached the screenshot also
Attached Images
File Type: jpg untitled.jpg (15.2 KB, 887 views)
Dec 15 '09 #1
5 6442
weaknessforcats
9,208 Recognized Expert Moderator Expert
Where is lib1.h located?

When you #include "lib1.h" it means that lib1.h is in the same directory as main.c OR lib1.h is in a directory that is along a pre-defined path.

When you #include <lib1.h>, it means that lib1.h is in a directory that is along a pre-defined path.

It looks like top need to pre-define a path. Go to your project settings for the preprocessor. It tis there you can specify additional directories for include files.
Dec 15 '09 #2
puneetsardana88
57 New Member
Coulnt find these options............


Please see the screenshot...
Attached Images
File Type: jpg untitled.jpg (15.9 KB, 298 views)
Dec 15 '09 #3
puneetsardana88
57 New Member
Ok After 1 hours of searching and testing I have been able to execute it. Now the question is to the other party we only give header files. So how can I organize libraries
Dec 15 '09 #4
Banfa
9,065 Recognized Expert Moderator Expert
No you will need to supply them with the header and the .a file.

What do you mean how do you organise libraries? Just pass them over the other party can put them in a convenient directory and link them into their program.
Dec 15 '09 #5
macerau
1 New Member
@puneetsardana88
Since you spent time figuring out the solution, why not share it?
didn't you come here to get someone's solution?
May 31 '20 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
5
by: Madhu R. Vajrala | last post by:
Hello All, I am very new to Python, trying to install it from source (ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/python-2.3.3.tar.gz) on Sun Solaris-9 (SPARC). But getting the below error...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
8
by: H. S. | last post by:
I am getting this error if I try to compile the file demarcated below. What I am missing here? I am using g++ (GCC) 3.3.5 (Debian 1:3.3.5-8). {tp2}> g++ -ansi -g -Wall tp2.cc -o tp2 tp2.cc: In...
1
by: TechBoy | last post by:
RE: Access 2002 When my app starts up I am trying to set the F11 key to a disabled state so users cannot press it to see the DBWindow. Here is the error: error msg: 3270-property not found ...
12
by: Sharon | last post by:
I’m wrote a small DLL that used the FreeImage.DLL (that can be found at http://www.codeproject.com/bitmap/graphicsuite.asp). I also wrote a small console application in C++ (unmanaged) that uses...
7
by: Martin Strojek | last post by:
Hi, I have the following problem with developing some web site. I use Visual Studio 2003 to build a website. I tried Windows 2003 Server and switched now back to Windows XP with PWS but the...
4
by: Sandy | last post by:
Hello - I read an interesting article on the web wherein the author states he doesn't handle too many errors at page level, but handles them at the application level. He further goes on to show...
7
by: Garth Wells | last post by:
I'm trying to create a DAL and am wondering what's the proper way to handle errors in this Insert method. public string Insert() { Database db = DatabaseFactory.CreateDatabase(); string...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.