GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-May-2007, 12:32
cornsnap cornsnap is offline
New Member
 
Join Date: May 2007
Posts: 11
cornsnap is on a distinguished road

basic question regarding compiling a program


Hello all,

Background: I am new to compiling programs.

I was asked to compile an X.lib file to be used on Solaris 9 and be compatible with C++ 5.5 patch 113817-19.

From my research C++ 5.5 came with Sun Studio 8. I do not have access to Sun Studio 8 therefore would it be possible to compile this using gcc 3.4.6? Or could I download and install Sun Studio 11, the newest version and compile this program?

In either case can someone give me general guidelines on how to go about compiling this lib. I was given two files:

X.cpp
X.h

I appreciate any information.

Thanks.
  #2  
Old 12-May-2007, 20:23
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 400
Peter_APIIT is on a distinguished road

Re: basic question regarding compiling a program


I couldn't understand what you say. Can you explained in detail ?
__________________
Linux is the best OS in the world.
  #3  
Old 13-May-2007, 18:20
cornsnap cornsnap is offline
New Member
 
Join Date: May 2007
Posts: 11
cornsnap is on a distinguished road

Re: basic question regarding compiling a program


When I do a g++ x.cpp I get this:

x.cpp:1:20: StdAfx.h: No such file or directory
In file included from x.cpp:2:
./x.h:8: error: using-declaration for non-member at class scope
./x.h:8: error: expected `;' before "Encrypt"
./x.h:9: error: using-declaration for non-member at class scope
./x.h:9: error: expected `;' before "Decrypt"
In file included from x.cpp:2:
./x.h:10:3: warning: no newline at end of file
x.cpp:13: error: expected constructor, destructor, or type conversion before
"x"
x.cpp:37: error: expected constructor, destructor, or type conversion before
"x"
  #4  
Old 13-May-2007, 21:43
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 400
Peter_APIIT is on a distinguished road
Thumbs up

Re: basic question regarding compiling a program


Are you compiling in text mode ?

I suggest you compile in a IDE environment because i also a linux user but normally i will compile at Eclipse. What distribution you are using ? You can ask this question in linux forum and post the answer in this forum.

Thanks.
__________________
Linux is the best OS in the world.
  #5  
Old 14-May-2007, 00:53
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 400
Peter_APIIT is on a distinguished road

Re: basic question regarding compiling a program


What GGC version are you using ? My compiler always no newline at the end of file.

I hope this will help others.
__________________
Linux is the best OS in the world.
  #6  
Old 14-May-2007, 08:50
cornsnap cornsnap is offline
New Member
 
Join Date: May 2007
Posts: 11
cornsnap is on a distinguished road

Re: basic question regarding compiling a program


I am using gcc version 3.4.6.

I am using Solaris 9.


currently I don't have and IDE to compile this program in. Could I compile without the IDE environment?

Thanks.
  #7  
Old 14-May-2007, 19:21
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: basic question regarding compiling a program


So, this code is apparently being ported from Visual C++ (hence the StdAfx error). There may or may not have been important stuff in StdAfx.h, but can you post all of X.cpp and X.h so we can look for the other errors?
  #8  
Old 14-May-2007, 20:43
cornsnap cornsnap is offline
New Member
 
Join Date: May 2007
Posts: 11
cornsnap is on a distinguished road

Re: basic question regarding compiling a program


Here are the two files. From what I know now is that this program may have been written as you said in Visual C++ and now they need it compiled in Solaris 9. Is this possible?

{ultra5-9 root} more StdEncryption.cpp

#include "StdAfx.h"
#include "./StdEncryption.h"
//#using <mscorlib.dll>

StdEncryption::StdEncryption(void)
{
}

StdEncryption::~StdEncryption(void)
{
}

std::string StdEncryption::Encrypt(std::string privateKey, std::string decrypted
Str){
int i, n, keyLen, strLen;
std::string strBuff;
char ch[2];
char testChar;

keyLen=privateKey.length();
if (keyLen==0){
return(decryptedStr);
}
else{
strLen=decryptedStr.length();
for(i=0; i<strLen; i++){
n = decryptedStr[i];
n = n + privateKey[(i+1) % keyLen];
testChar=(char)(n & 0xFF);
ch[0]=testChar;
ch[1]='\0';
strBuff.append(ch);
}
}
return(strBuff);
}

std::string StdEncryption:ecrypt(std::string privateKey, std::string encrypted
Str){
int i, n, keyLen, strLen;
std::string strBuff;
char ch[2];
char testChar;

keyLen=privateKey.length();
if (keyLen==0){
return(encryptedStr);
}
else{
strLen=encryptedStr.length();
for(i=0; i<strLen; i++){
n = encryptedStr[i];
n = n - privateKey[(i+1) % keyLen];
testChar=(char)(n & 0xFF);
ch[0]=testChar;
ch[1]='\0';
strBuff.append(ch);
}
}
return(strBuff);
}

{ultra5-9 root} more StdEncryption.h

#pragma once

class StdEncryption
{
public:
StdEncryption(void);
~StdEncryption(void);
std::string Encrypt(std::string privateKey, std::string decryptedStr);
std::string Decrypt(std::string privateKey, std::string encryptedStr);
};
  #9  
Old 14-May-2007, 20:59
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,621
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: basic question regarding compiling a program


Quote:
Originally Posted by cornsnap
Here are the two files. From what I know now is that this program may have been written as you said in Visual C++ and now they need it compiled in Solaris 9. Is this possible?

StdEncryption.h:
CPP / C++ / C Code:
#ifndef STDENCRYPTION_H__
#define STDENCRYPTION_H__
#include <string>
class StdEncryption {
  public:
    StdEncryption(void);
    ~StdEncryption(void);
     std::string Encrypt(std::string privateKey, std::string decryptedStr);
     std::string Decrypt(std::string privateKey, std::string encryptedStr);
};
#endif

StdEncryption.cpp (or StdEncryption.C or StdEncryption.cxx or whatever convention your installation likes for C++ source files)

CPP / C++ / C Code:
#include <string>
#include "./StdEncryption.h"

StdEncryption::StdEncryption(void)
{
}

StdEncryption::~StdEncryption(void)
{
}

std::string StdEncryption::Encrypt(std::string privateKey,
                                   std::string decryptedStr)
{
    int i, n, keyLen, strLen;
    std::string strBuff;
    char ch[2];
    char testChar;

    keyLen = privateKey.length();
    if (keyLen == 0) {
        return (decryptedStr);
    }
    else {
        strLen = decryptedStr.length();
        for (i = 0; i < strLen; i++) {
            n = decryptedStr[i];
            n = n + privateKey[(i + 1) % keyLen];
            testChar = (char) (n & 0xFF);
            ch[0] = testChar;
            ch[1] = '\0';
            strBuff.append(ch);
        }
    }
    return (strBuff);
}

std::string StdEncryption::Decrypt(std::string privateKey,
                                   std::string encryptedStr)
{
    int i, n, keyLen, strLen;
    std::string strBuff;
    char ch[2];
    char testChar;

    keyLen = privateKey.length();
    if (keyLen == 0) {
        return (encryptedStr);
    }
    else {
        strLen = encryptedStr.length();
        for (i = 0; i < strLen; i++) {
            n = encryptedStr[i];
            n = n - privateKey[(i + 1) % keyLen];
            testChar = (char) (n & 0xFF);
            ch[0] = testChar;
            ch[1] = '\0';
            strBuff.append(ch);
        }
    }
    return (strBuff);
}

Should compile with any standard C++ compiler installation. Ready for testing/debugging.

Regards,

Dave
  #10  
Old 14-May-2007, 22:33
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 400
Peter_APIIT is on a distinguished road

Re: basic question regarding compiling a program


Hello cornsnap. can you explain a bit what do this program acts?

Are you wrote the program ?

Thanks.
__________________
Linux is the best OS in the world.
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
BOOKEEPING program, HELP!! yabud C Programming Language 10 17-Nov-2006 03:48
Pipeline freeze simulation darklightred CPP / C++ Forum 6 27-Jul-2006 19:37
creating a file in [c] i hate c C Programming Language 15 21-Nov-2005 12:52
Help needed on visual C++ basic math program xoBeBExo CPP / C++ Forum 5 18-Nov-2005 01:52
Enter key in basic c program hopesfall C Programming Language 2 26-Mar-2005 16:09

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:07.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.