Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

KVM on Solaris 8 (64bit OS)

Posted on 2002-06-13
17
Medium Priority
?
402 Views
Last Modified: 2013-12-20
Hi,

I'm writing a code on Solaris 8 OS to scaning the process environment area using the following code:
========================================================
  if (!(kd = kvm_open(NULL, NULL, NULL, O_RDONLY, argv[0]))) {
            perror("kvm_open");  
            exit(1);
         }

         kvm_setproc(kd);
         fndarg=0;cnt=0;
         while ((pCurProc = kvm_nextproc(kd)) != NULL)
         {
           if((pUsrEnv = kvm_getu(kd, pCurProc))!=NULL)
           {
             kvm_getcmd(kd, pCurProc, pUsrEnv, &usrArg,&env);
             sprintf(sbuf,"ppid=[%d]",pCurProc->p_ppid);
             strcpy(abbuf[cnt],usrArg[0]);
             strcat(abbuf[cnt],sbuf);
           }  
           ++cnt;
         }
         
   kvm_close(kd);
=======================================================


this code works on Sol2.6 but doesn't work in Sol 8   (sun4u sparc SUNW,Ultra-5_10).
I got an error of:
# ./procenv
./procenv: /dev/ksyms is not a 32-bit kernel namelist

I'm also using the following command line to compile:
gcc -o procenv procenv.c -lkvm

My question is:

How can I make this code run on Sol 8 or what are the compile option to use to make this code run of Sol 8.

Thanks in advance


 
0
Comment
Question by:nsum
  • 8
  • 6
  • 3
17 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7075096
you need a libkvm.a or libkvm.so for 64-bit support, check with:

   find /usr/lib -name libkvm\*
   find /lib -name libkvm\*
0
 

Author Comment

by:nsum
ID: 7075106
Hi ahoffmann,

Thanks for you prompt response. There is a 64-bit libkvm (I believe) under /usr/lib/64 but how can I point to this library during compilation. I have already tried using the option -L /usr/lib/64. Sorry I forgot to include in my question that I have looked and tried the /usr/lib/64/lib's

regards,
nsum





0
 

Author Comment

by:nsum
ID: 7075109
Hi ahoffmann,

Thanks for you prompt response. There is a 64-bit libkvm (I believe) under /usr/lib/64 but how can I point to this library during compilation. I have already tried using the option -L /usr/lib/64. Sorry I forgot to include in my question that I have looked and tried the /usr/lib/64/lib's

regards,
nsum





0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 7075155
should work like this:

   gcc -o procenv procenv.c -L /usr/lib/64 -lkvm

or if it fails, try using lib exxplicitely:

   gcc -o procenv procenv.c /usr/lib/64/libkvm.a
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7077002
The fast way to verifile the kvms are there or not, use:

pkginfo | grep kvm

you should see something like
   SUNkvm SUNkvmx as output.

than try ahoffmann's example above
0
 

Author Comment

by:nsum
ID: 7077052
I've tried
gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
and
gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
in the first place.  BTW /usr/lib/64 is linked to /usr/lib/sparcv9.

I can't find /usr/lib/64/libkvm.a
Is there other way?

Thanks in advance
nsum
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7077531
Sun does not ship a libkvm.a library. Theoretically, you could obtain the Solaris 8 source code and build your own libkvm.a for linking.

0
 

Author Comment

by:nsum
ID: 7077749
There should be other way to compile using the /usr/lib/64/libkvm.  
Or do I need to change my "gcc" version I believe I'm using
gcc 2.7.2.1.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7077817
> .. There is a 64-bit libkvm (I believe) under /usr/lib/64  ..
and what's the name of it?
use it as parameter to the gcc command as suggested before

IT#s a library, not a gcc problem.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7078329
there is a libkvm.so in /usr/lib/64
0
 

Author Comment

by:nsum
ID: 7082904
I believe I've tried that before, here's the summary what I've already tried (But still didn't work):

1.) gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
2.) gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
3.) gcc -o procenv procenv.c /usr/lib/64/libkvm.a (no libkvm.a )
4.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so.1 5.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7083283
does this mean that they all produce the same error?
Then there is probably something wrong with the libs.
0
 

Author Comment

by:nsum
ID: 7084741
Sorry I have not given a little detailed:

1.) gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
   error: Compilation OK, But will not work (
                 ./procenv: /dev/ksyms is not a 32-bit kernel namelist)

2.) gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
    error: the same as number 1 result

3.) gcc -o procenv procenv.c /usr/lib/64/libkvm.a (no libkvm.a )
    error: libkvm.a not found, compilation not done.

4.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so.1
    error: Will not compile, lot of errors during compilation.

5.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so
     error: the same as number 4 result

6.) gcc -o procenv procenv.c -m64 -lkvm
      error: gcc -m64 -L /usr/lib/64 -lkvm -o procenv procenv.c
cc1: -m64 is not supported by this configuration
cc1: -mptr32 not allowed on -m64

I have also installed the GCC 3.1 just incase it will work (still the same problem) even I know that the problem is the lib. I'm already lost, I don't know what to do.
If only there's other way to compile using gcc and produce a 64bit executable.

I'll increase the points to 300
Please help I'm stack with this problem for days....

Regards,
nsum
0
 

Author Comment

by:nsum
ID: 7084743
Sorry I have not given a little detailed:

1.) gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
   error: Compilation OK, But will not work (
                 ./procenv: /dev/ksyms is not a 32-bit kernel namelist)

2.) gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
    error: the same as number 1 result

3.) gcc -o procenv procenv.c /usr/lib/64/libkvm.a (no libkvm.a )
    error: libkvm.a not found, compilation not done.

4.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so.1
    error: Will not compile, lot of errors during compilation.

5.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so
     error: the same as number 4 result

6.) gcc -o procenv procenv.c -m64 -lkvm
      error: gcc -m64 -L /usr/lib/64 -lkvm -o procenv procenv.c
cc1: -m64 is not supported by this configuration
cc1: -mptr32 not allowed on -m64

I have also installed the GCC 3.1 just incase it will work (still the same problem) even I know that the problem is the lib. I'm already lost, I don't know what to do.
If only there's other way to compile using gcc and produce a 64bit executable.

I'll increase the points to 300
Please help I'm stack with this problem for days....

Regards,
nsum
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 600 total points
ID: 7086534
hmm, sounds to me that gcc does not produce compatible code for Sun's 64-bit libs.
Can you use Sun's bundled cc and ld?
Otherwise you have to find a propper compiler (gcc 3.1), sorry I have no experiance abozt "propper".
0
 

Author Comment

by:nsum
ID: 7091505
I don't have bundled cc intalled.. I thnk I have to hold this question  until I find other options. Anyway, I'll accept these comments of ahoffmann for an answer for now.

Thanks everybody
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7091659
Thanks.
Feel free to com e back on this question if you need ..
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question