Solved

KVM on Solaris 8 (64bit OS)

Posted on 2002-06-13
17
395 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 300 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
no14 challenge 14 69
How to convert MFC::CString to UTF8 wchar_t* 10 214
Unix Script: Loop over all days of a month 17 99
Wrap Oraccle SQL*Plus executable Command 4 84
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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 how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

822 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