LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-11-2016, 05:45 AM   #1
sindh
LQ Newbie
 
Registered: Aug 2014
Posts: 28

Rep: Reputation: Disabled
Compiler errors when migrating code from solaris to Linux sandbox


We are trying to migrate from solaris to Linux.
As part of that, I tried installing the c++ compiler on sandbox(RHEL 7). Mentioning the versions below.

On solaris
---------------
$ gcc -v
Reading specs from /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/specs
Configured with: /gates/sfw10/builds/sfw10-gate/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)


On Sandbox RHEL 7
-------------------
[root@scsblnx-199494 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.3/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)


And I am getting 3 kinds of errors like mentioned below. And I have never got these when compiled on solaris. Can someone help me on solving this?


1.
error: previous declaration \342\200\230int madvise(caddr_t, size_t, int)\342\2
00\231 here
extern "C" int madvise(caddr_t, size_t, int);

2.
error: \342\200\230contains\342\200\231 was not declared in this scope, a
nd no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
if(!contains(item))
^
3.
error: \342\200\230reallocItemsArray\342\200\231 was not declared in this
scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
reallocItemsArray(_itemsCount+1,bottomFromContains);
^
 
Old 02-11-2016, 08:29 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,866

Rep: Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487
#1 appears to be a c++ construct being used in C. This could happen if the configuration file? or compiler options miss a definition directive to skip it.

#2 and #3 may be cascading errors from the first one.
 
1 members found this post helpful.
Old 02-11-2016, 09:41 AM   #3
sindh
LQ Newbie
 
Registered: Aug 2014
Posts: 28

Original Poster
Rep: Reputation: Disabled
I will check that from my code.

But do you think, I need to make some environmental changes?
or some prerequisites?
Because, It's just a fresh box, and I tried installing compilers on it.
 
Old 02-11-2016, 10:55 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,866

Rep: Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487
It usually depends on how the application itself is configured.

Most of the system includes are formatted like:

Code:
...
#ifdef __cplusplus
extern "C" }
#endif
...
The symbol __cplusplus was defined for use by the C++ compiler, and the C compiler doesn't define it.

If the application build process uses a different symbol for something similar, then that could be the missing item.

It can be defined/not defined by a CFLAGS make variable to be passed to the compiler during a make (assuming the build process was based on make).
 
2 members found this post helpful.
Old 02-12-2016, 06:57 AM   #5
sindh
LQ Newbie
 
Registered: Aug 2014
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thank you very much for your response.
I was able to solve these errors.

1.#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 2) || defined (__EXTENSIONS__)
extern "C" int madvise(caddr_t, size_t, int);
#endif

I have commented the above code. And I didn't get the first error.
Is there any other way, I can solve this?

2. The compiler was not able to interpret some function calls. So I need to add this-> for few function calls.
3. While type casting some address to int, got the error losing precision. So I made it long. That's how it got solved.

And finally, after compiling, I am getting the linker error.
/usr/bin/ld: cannot find -lmisc
ld returned 1 exit status


How to check that library is available on RHEL 7? And How to set path and compile?
 
Old 02-12-2016, 07:51 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,866

Rep: Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487
You might use
Code:
#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 2) || defined (__EXTENSIONS__)
extern "C" int madvise(caddr_t, size_t, int);
#else
extern int madvise(caddr_t, size_t, int);
#endif
This way you get a C protototype.

But I'm not sure from the example you gave whether it would work or not. But this might also address your #2 issue.

#3 is a missing library, you will have to find that one, or identify the package it is in and install that package. It is possible the library might be called "libXxf86misc.so.*" instead (I don't have a libmisc.*). Since you are generating a 32 bit application, make sure it is the 32 bit version you get (I'm on a 64 bit system, so I could be wrong about the name).

Last edited by jpollard; 02-12-2016 at 07:52 AM.
 
Old 02-12-2016, 08:18 AM   #7
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,600

Rep: Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116
you may try to remove -lmisc and check the unresolved symbols you get. Probably you will be able to replace it, but also you may need to rewrite that part of the code (or construct a wrapper).
 
Old 02-15-2016, 07:14 AM   #8
sindh
LQ Newbie
 
Registered: Aug 2014
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thank you very much for your replies.

I still have this issue.
/usr/bin/ld: cannot find -lmisc
ld returned 1 exit status



How can I find the exact library name I need, and can I get it installed through yum
 
Old 02-15-2016, 07:26 AM   #9
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,600

Rep: Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116
libmisc*.so where * is something like a version number - or nothing. Probably that lib exists only on solaris. Or you can check it here: https://sourceforge.net/projects/libmisc/
 
Old 02-15-2016, 08:59 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,866

Rep: Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487
Quote:
Originally Posted by sindh View Post
Thank you very much for your replies.

I still have this issue.
/usr/bin/ld: cannot find -lmisc
ld returned 1 exit status



How can I find the exact library name I need, and can I get it installed through yum
Try leaving the library out.

You may not need the functions in it.
 
Old 02-19-2016, 05:21 AM   #11
sindh
LQ Newbie
 
Registered: Aug 2014
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thank you for all your replies. lmisc is an internal library that we are creating in our code.
 
Old 02-19-2016, 06:18 AM   #12
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,600

Rep: Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116Reputation: 5116
so you will need: -L<path_to_libmisc> -lmisc
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Migrating from Solaris 11 to a Linux distro. RHEL 7 or SuSe 12 erj Red Hat 3 11-18-2014 05:08 AM
[SOLVED] emerge sandbox fails with compiler error MarcusWebb1966 Gentoo 3 10-03-2012 04:09 AM
Protecting PHP Source Code by VirtualBox Sandbox overkillblack Linux - Security 8 02-13-2012 08:58 AM
problem with Migrating code base from windows to linux mohit.malik Linux - General 2 01-10-2007 09:49 AM
migrating C code from linux to windows Paula01 Linux - General 2 03-13-2002 11:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:33 PM.

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