Closed SanPen closed 1 year ago
SCIP_EXPORT
seems to get defined wrongly. It should be defined to __declspec(dllexport)
when using MSVC, but somehow you get the GCC/clang variant __attribute__((__visibility__("default")))
.
The place where SCIP_EXPORT
gets defined depends a bit on your SCIP installation. You might want to look into that.
Hi!,
I see SCIP_EXPORT
being exported in def.h
I'm including #include "scip/scip.h"
¿Do you have an idea of what can be going on?
As far as I know I have not messed with SCIP_EXPORT
.
It gets defined in def.h
if it hasn't been defined already. Maybe you could just look at the code after the C preprocessor has been running (there should be some flag for MSVC to output this; it's -E
with gcc). That should show more clearly where SCIP_EXPORT
gets defined to which value.
My guess is that you have an installation of SCIP that was build via cmake on Linux. In the case, there is a scip/scip_export.h
somewhere which defines SCIP_EXPORT
to be __attribute__((visibility("default")))
, which will not work with MS compilers. But there is not enough information given here to say for sure what is happening.
Indeed I have the file scip/scip_export.h
.
So this file should not be there for windows?
THe content of the file is:
#ifndef SCIP_EXPORT_H
#define SCIP_EXPORT_H
#ifdef SCIP_STATIC_DEFINE
# define SCIP_EXPORT
# define SCIP_NO_EXPORT
#else
# ifndef SCIP_EXPORT
# ifdef libscip_EXPORTS
/* We are building this library */
# define SCIP_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define SCIP_EXPORT __attribute__((visibility("default")))
# endif
# endif
# ifndef SCIP_NO_EXPORT
# define SCIP_NO_EXPORT __attribute__((visibility("hidden")))
# endif
#endif
#ifndef SCIP_DEPRECATED
# define SCIP_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef SCIP_DEPRECATED_EXPORT
# define SCIP_DEPRECATED_EXPORT SCIP_EXPORT SCIP_DEPRECATED
#endif
#ifndef SCIP_DEPRECATED_NO_EXPORT
# define SCIP_DEPRECATED_NO_EXPORT SCIP_NO_EXPORT SCIP_DEPRECATED
#endif
#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef SCIP_NO_DEPRECATED
# define SCIP_NO_DEPRECATED
# endif
#endif
#endif /* SCIP_EXPORT_H */
Do you believe that it is ok to modify this to handle the OS config?
You can try whether changing the content to
#ifndef SCIP_EXPORT
#define SCIP_EXPORT __declspec(dllimport)
#endif
works better, assuming your want to link to a SCIP DLL later.
That gets fixed, but I get the same issue with SCIP_DEPRECATED
.
What should be the windows version for that one?
Thanks
Well this is scip_export.h
now:
#ifndef SCIP_EXPORT_H
#define SCIP_EXPORT_H
#ifdef SCIP_STATIC_DEFINE
//# define SCIP_EXPORT
# if defined(_WIN32) || defined(_WIN64)
# define SCIP_EXPORT __declspec(dllexport)
# elif defined(__APPLE__) || defined(LINUX) || defined(linux)
# define SCIP_EXPORT __attribute__((visibility("default")))
# endif
# define SCIP_NO_EXPORT
#else
# ifndef SCIP_EXPORT
# ifdef libscip_EXPORTS
/* We are building this library */
# if defined(_WIN32) || defined(_WIN64)
# define SCIP_EXPORT __declspec(dllexport)
# elif defined(__APPLE__) || defined(LINUX) || defined(linux)
# define SCIP_EXPORT __attribute__((visibility("default")))
# endif
# else
/* We are using this library */
# if defined(_WIN32) || defined(_WIN64)
# define SCIP_EXPORT __declspec(dllexport)
# elif defined(__APPLE__) || defined(LINUX) || defined(linux)
# define SCIP_EXPORT __attribute__((visibility("default")))
# endif
# endif
# endif
#ifndef SCIP_EXPORT
# if defined(_WIN32) || defined(_WIN64)
# define SCIP_EXPORT __declspec(dllimport)
# elif defined(__APPLE__) || defined(LINUX) || defined(linux)
# define SCIP_EXPORT __attribute__((visibility("default")))
# endif
#endif
# ifndef SCIP_NO_EXPORT
# define SCIP_NO_EXPORT __attribute__((visibility("hidden")))
# endif
#endif
#ifndef SCIP_DEPRECATED
# if defined(_WIN32) || defined(_WIN64)
# define SCIP_DEPRECATED __declspec(deprecated)
# elif defined(__APPLE__) || defined(LINUX) || defined(linux)
# define SCIP_DEPRECATED __attribute__ ((__deprecated__))
# endif
#endif
#ifndef SCIP_DEPRECATED_EXPORT
# define SCIP_DEPRECATED_EXPORT SCIP_EXPORT SCIP_DEPRECATED
#endif
#ifndef SCIP_DEPRECATED_NO_EXPORT
# define SCIP_DEPRECATED_NO_EXPORT SCIP_NO_EXPORT SCIP_DEPRECATED
#endif
#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef SCIP_NO_DEPRECATED
# define SCIP_NO_DEPRECATED
# endif
#endif
#endif /* SCIP_EXPORT_H */
It works as horrific it may be...
@svigerske is that a change we should also do upstream?
No, this looks like a user doing something wrong, but not telling enough to find the source of the problem. I gave my guess and instructions to investigate, but that seemed to have been ignored. Since the user found a workaround, this can be closed.
The scip_export.h
is autogenerated during the build if using cmake. So you won't need one that works for both worlds (MSVC and GCC). Also, the scip_export.h
in https://www.scipopt.org/download.php?fname=SCIPOptSuite-8.0.4-win64-VS15.exe looks correct:
#ifndef SCIP_EXPORT_H
#define SCIP_EXPORT_H
#ifdef SCIP_STATIC_DEFINE
# define SCIP_EXPORT
# define SCIP_NO_EXPORT
#else
# ifndef SCIP_EXPORT
# ifdef libscip_EXPORTS
/* We are building this library */
# define SCIP_EXPORT __declspec(dllexport)
# else
/* We are using this library */
# define SCIP_EXPORT __declspec(dllimport)
# endif
# endif
# ifndef SCIP_NO_EXPORT
# define SCIP_NO_EXPORT
# endif
#endif
#ifndef SCIP_DEPRECATED
# define SCIP_DEPRECATED __declspec(deprecated)
#endif
#ifndef SCIP_DEPRECATED_EXPORT
# define SCIP_DEPRECATED_EXPORT SCIP_EXPORT SCIP_DEPRECATED
#endif
#ifndef SCIP_DEPRECATED_NO_EXPORT
# define SCIP_DEPRECATED_NO_EXPORT SCIP_NO_EXPORT SCIP_DEPRECATED
#endif
#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef SCIP_NO_DEPRECATED
# define SCIP_NO_DEPRECATED
# endif
#endif
#endif /* SCIP_EXPORT_H */
(MSVC-style __declspec
instead of GCC-style __attribute__
)
Just to provide a bit of context.
What I am doing is to copy the headers in a folder called ThridParty/solvers/scip/8.0.3
because later I dynamically search and load the .dll/.so file. This is being done with other libraries with zero issues.
Why?
Because I want to be able to compile binaries with all the functionality without having to rely on the machine. I know a common practice is to use cmake to download the dependencies. But that has not worked great in the past and I need to provide a compilable source code to several environments with minimal dependencies (cmake, gcc/msvc and that's it)
I see from the comments, that what I should have is two sets of scip header; one for windows and one for unix. I really believe this is overkill, given that the only difference is a file.
Just my 2 cents.
Hi,
I included the scip 8.0.3 headers in a c++ program I'm making. Under ubuntu gcc all compiles fine, but under windows I'm getting some errors pointing at the scip headers that I have no idea what to make of:
This happens when compiling under windows 10, MSVC 2022.
Maybe I am missing something here.