Sytemc on centos 5.3 64bit

Source: Internet
Author: User
ArticleDirectory
    • System Environment
    • Fault Cause
    • Solution
    • Practical drills
System Environment
    • Centos 5.3 64bit
    • GCC 4.1
    • EMC 2.2

 

Operation Purpose
    • Compile the EMC module into. So from externalProgramCall

 

Fault
    • During compilation, GCC indicates that libsystemc. A needs to be compiled using the-FPIC switch, and the module cannot find the symbol.

 

Fault Cause
    • Libsystemc. A needs to be compiled into pic to import the EMC module into. So.Code. By default, gcc4 does not enable the-FPIC switch.

 

Solution
    • Open the configure. In file and add-FPIC to the-wall switch on the Linux x86_64 platform. Run the distinstall and bootup scripts in the config directory to generate new configurations. Then it works normally./configure, make, make install, and make clean.

 

Practical drills
    • Declare a. So file named "trust", and then execute this. So file in an external program (in fact, manually execute the function in. So ). The code for the two files is as follows.
Code # Include < Iostream >
# Include < EMC. h >

Using NamespaceSTD;

SC _module (first_counter)
{
SC _ctor (first_counter ){
Cout<"Trust"<Endl;
}
};

Int SC _main ( Int Argc, Char * Argv [])
{
Cout < " SC _main running! " < Endl;
For ( Int I = 0 ; I < Argc; ++ I)
{
Cout < ' \ T ' < Argv [I] < Endl;
}
First_counter C1 ( " C1 " );
Return   0 ;
}

# DefineExport _ attribute _ (visibility ("default ")))

Extern   " C "
{
Export
Void Fork ( Int N, Int M)
{
Char ** Argv = ( Char ** ) Malloc ( Sizeof ( Void * ) * 2 );

CharBuf [256];

Sprintf (BUF,"% D", N );
Argv [0]=Strdup (BUF );

sprintf (BUF, " % d " , m);
argv [ 1 ] = strdup (BUF);

SC _main (2, Argv );

Free (argv [0]);
Free (argv [1]);
Free (argv );
}
}

 

Code # Include < Dlfcn. h >
# Include < Iostream >

Using NamespaceSTD;

TypedefVoid(*Pfnvoidint )(Int,Int);

int main ( int argc, char * argv [])
{< br> void * handle = dlopen ( " /home/bo/projects/Trust/libtrust. so " , rtld_lazy );

Pfnvoidint forkfunc=(Pfnvoidint) dlsym (handle,"Fork");

If(Forkfunc)
Forkfunc (1234567890,1122334455);

Dlclose (handle );
Return 0;
}

the execution result is completely normal. The parameters are correctly transmitted to the EMC module. So.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.