LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-31-2018, 12:39 AM   #1
rahulvishwakarma
Member
 
Registered: Aug 2010
Posts: 138

Rep: Reputation: 2
how to create and use shred library in codeblocks


hi to all
i've centos 6.6 and codeblocks 16.01. i want to build shared object library file. I chosed as

new->project->shared library, then language c then project title as C. and project title as

int_vlaid.now given following code in

intvalidation.c
----------------
Code:
 #include "intvalidation.h"

int intvalidation(const char * iint)
{
    int i = 0, count = 0, len;
    //unsigned long long int num = 0;

    char * strnum = 0, chnum = 0;

    strnum = (char *) malloc(sizeof (20));

    //sprintf(strnum, "%d", iint);

    len = strlen(iint);

    printf(" len = %d ", len);

    for( count = 0; count < len; count++)
    {
        chnum = (*(iint + count )) ;

        i = chnum - 48;
        if( i >=  0 && i <= 9 )
            continue;
        else
        {
           // printf("\n number is not valid \n");
            return 0;
        }
    }

    return 1;
}
in intvalidation.h
-------------------
Code:
#ifndef INTVALIDATION_H
#define INTVALIDATION_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int intvalidation(const char * iint);

#endif
in man.c file of second project :-
----------------------------------
Code:
#include <stdio.h>
#include <stdlib.h>

int intvalidation(char *iint);
int AddInt(int i1, int i2);

int main()
{
    unsigned int x, y, sum = 0;
    char *num1, *num2;

    num1 = (char *)malloc(6);

    printf("\n Enter number x = ");
    scanf("%s", num1);

    if(!intvalidation(num1))
    {
        printf("\n number %s is invalid \n", num1);
        exit(1);
    }

    x = atoi(num1);

    num2 = (char*) malloc(6);

    printf( "\n Enter number to add: ");
    scanf("%s", num2);

    if(!intvalidation(num1))
    {
        printf("\n number %s is invalid \n", num2);
        exit(1);
    }

    y = atoi(num2);

    //sum = x + y;
    sum = AddInt(x, y);

    printf("\n %d + %d = %d", x, y, sum);

    return 0;
}
now when i compile first project ( int_valid )
thsi generates sharedfile as :-

"liblibint_vaild.so"

why it is having two "lib" not a single one lib.
and second thing that how to link library file in our project.
 
Old 03-31-2018, 09:21 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,788

Rep: Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001
Quote:
Originally Posted by rahulvishwakarma View Post
hi to all
i've centos 6.6 and codeblocks 16.01. i want to build shared object library file. I chosed as

new->project->shared library, then language c then project title as C. and project title as

int_vlaid.now given following code in

now when i compile first project ( int_valid ) thsi generates sharedfile as :- "liblibint_vaild.so"

why it is having two "lib" not a single one lib. and second thing that how to link library file in our project.
Confused about this thread, since you've been asking about C coding and Codeblocks for at least eight years now:
https://www.linuxquestions.org/quest...-i-use-824894/
https://www.linuxquestions.org/quest...or-4175620326/
https://www.linuxquestions.org/quest...ut-4175539099/
https://www.linuxquestions.org/quest...ng-4175508606/

This is probably due to your Codeblocks setup; check your settings.
 
Old 03-31-2018, 10:32 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Someone is keeping track of your doings rahulvishwakarma.
 
Old 03-31-2018, 10:49 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,788

Rep: Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001
Quote:
Originally Posted by BW-userx View Post
Someone is keeping track of your doings rahulvishwakarma.
I try to look at posting history when I remember a particular user. Always odd when someone says they've been working with something for years, and asks questions about the basics.
 
Old 03-31-2018, 11:05 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by TB0ne View Post
I try to look at posting history when I remember a particular user. Always odd when someone says they've been working with something for years, and asks questions about the basics.
were you a hall monitor in your youth?

odd? well ... some only take what they want to learn and what they need to learn to get it to work and should learn and keep them separated. which as we see can hinder more then do good.

the Ole, ask when needed then keeps kicking in. But, yes, he should know how to do his setup to compile whatever it is he is writing by now. I've only used codeblocks a few times, and again am currently and I am happy to report that remembered that part.

Last edited by BW-userx; 03-31-2018 at 11:09 AM.
 
Old 03-31-2018, 11:12 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by rahulvishwakarma View Post
hi to all
i've centos 6.6 and codeblocks 16.01. i want to build shared object library file. I chosed as

new->project->shared library, then language c then project title as C. and project title as

now when i compile first project ( int_valid )
thsi generates sharedfile as :-

"liblibint_vaild.so"

why it is having two "lib" not a single one lib.
and second thing that how to link library file in our project.
just to take a guess at this.

I'd think you'd build your lib so , put it somewhere safe then link it in your second project to that projects .so file.

Last edited by BW-userx; 03-31-2018 at 11:13 AM.
 
Old 03-31-2018, 02:46 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,788

Rep: Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001
Quote:
Originally Posted by BW-userx View Post
were you a hall monitor in your youth?
Little need for that towards me.
Quote:
odd? well ... some only take what they want to learn and what they need to learn to get it to work and should learn and keep them separated. which as we see can hinder more then do good.

the Ole, ask when needed then keeps kicking in. But, yes, he should know how to do his setup to compile whatever it is he is writing by now. I've only used codeblocks a few times, and again am currently and I am happy to report that remembered that part.
I've said many times in the past, that I never mind helping someone. But at some point, that person is going to have to do for themselves. After being here for eight years, using Codeblocks for at least 4, and hardly EVER replying/saying thank-you/following-up/marking solved, that time is past.
 
Old 03-31-2018, 03:23 PM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by TB0ne View Post
Little need for that towards me.
No insult intended if you took it that way. one that pays attention to details about people and holds them accountable, was all it meant.
Quote:
Originally Posted by TB0ne View Post
I've said many times in the past, that I never mind helping someone. But at some point, that person is going to have to do for themselves. After being here for eight years, using Codeblocks for at least 4, and hardly EVER replying/saying thank-you/following-up/marking solved, that time is past.
ok.
 
Old 03-31-2018, 04:01 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,788

Rep: Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001
Quote:
Originally Posted by BW-userx View Post
No insult intended if you took it that way. one that pays attention to details about people and holds them accountable, was all it meant.
Understood, and thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I create a Shared library? Reina Programming 1 08-12-2007 11:14 PM
how to create a share library abd_bela Programming 2 07-16-2007 10:24 AM
Trying to create a shared library mukund_desh Linux - Software 1 05-24-2005 05:41 AM
create a library os2 Programming 4 06-30-2004 10:29 PM
How to create a .deb library package? FloFri Debian 3 05-03-2004 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration