casadi_os.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010 by Joel Andersson, Moritz Diehl, K.U.Leuven. All rights reserved.
6  *
7  * CasADi is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 3 of the License, or (at your option) any later version.
11  *
12  * CasADi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with CasADi; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  */
22 
23 #ifndef CASADI_CASADI_OS_HPP
24 #define CASADI_CASADI_OS_HPP
25 
26 #include <casadi/core/casadi_export.h>
27 #include <vector>
28 #include <string>
29 
31 
32 
33 // For dynamic loading
34 #ifdef WITH_DL
35 #ifdef _WIN32 // also for 64-bit
36 #ifndef NOMINMAX
37 #define NOMINMAX
38 #endif
39 #ifndef _WIN32_WINNT
40 #define _WIN32_WINNT 0x0502
41 #endif
42 #include <windows.h>
43 // Avoid IN/OUT macros that may interfere with CasADi code
44 #ifdef IN
45 #undef IN
46 #endif
47 #ifdef OUT
48 #undef OUT
49 #endif
50 #ifdef interface
51 #undef interface
52 #endif
53 #else // _WIN32
54 #include <dlfcn.h>
55 #endif // _WIN32
56 
57 // Set default shared library prefix
58 #ifndef SHARED_LIBRARY_PREFIX
59 #define SHARED_LIBRARY_PREFIX CASADI_SHARED_LIBRARY_PREFIX
60 #endif // SHARED_LIBRARY_PREFIX
61 
62 
63 // Set default shared library suffix
64 #ifndef SHARED_LIBRARY_SUFFIX
65 #define SHARED_LIBRARY_SUFFIX CASADI_SHARED_LIBRARY_SUFFIX
66 #endif // SHARED_LIBRARY_SUFFIX
67 #endif // WITH_DL
68 
69 namespace casadi {
70 
71 CASADI_EXPORT std::vector<std::string> get_search_paths();
72 
73 /* \brief Get the file separator (: or ;)
74  */
75 CASADI_EXPORT char pathsep();
76 /* \brief Get the file separator (/ or \‍)
77  */
78 CASADI_EXPORT std::string filesep();
79 
80 // For dynamic loading
81 #ifdef WITH_DL
82 
83 #ifdef _WIN32
84  typedef HINSTANCE handle_t;
85 #else // _WIN32
86  typedef void* handle_t;
87 #endif
88 
89 CASADI_EXPORT handle_t open_shared_library(const std::string& lib,
90  const std::vector<std::string> &search_paths,
91  std::string &resultpath,
92  const std::string& caller, bool global=false);
93 
94 CASADI_EXPORT handle_t open_shared_library(const std::string& lib,
95  const std::vector<std::string> &search_paths,
96  const std::string& caller, bool global=false);
97 
103 CASADI_EXPORT int close_shared_library(handle_t handle);
104 
105 #endif // WITH_DL
106 
107 
108 
109 } // namespace casadi
110 
112 
113 #endif // CASADI_SHARED_LIBRARIES_HPP
The casadi namespace.