I'm trying to compile/port an older version of OpenOffice. It uses Boost v1.34.1, which is part of the source tree. The error message is as follows:
Undefined symbols:
"boost::throw_exception(std::exception const&)", referenced from:
boost::detail::shared_count::shared_count<ScToken>(ScToken*)in detfunc.o
ld: symbol(s) not found
Boost is new to me, and I haven't been able to find much online to help me understand this. From the error message, I understand that I probably need to link a library. However, boost::throw_exception is defined in a header file with no matching library (that I can find). Just for kicks, I've tried #include <boost/throw_exception.hpp> in detfunc and using symbolic links to put the header file in the same directory with no luck.
Is there a library I should be linking with -l or an include path with -I? How should I get that symbol referenced in?
Boost expects the project either to be built with macro BOOST_NO_EXCEPTIONS undefined, or to define the function boost::throw_exception itself.
From <boost/throw_exception.hpp> in version 1.34.1:
namespace boost
{
#ifdef BOOST_NO_EXCEPTIONS
void throw_exception(std::exception const & e); // user defined
#else
//[Not user defined --Dynguss]
template<class E> inline void throw_exception(E const & e)
{
throw e;
}
#endif
} // namespace boost
Boost's configuration headers will determine whether to define the macro or not. It looks like it boils down to the compiler you're using, but there may be other factors. Take a look in the boost/config/compiler/ folder for the header file that corresponds to your compiler, then search for BOOST_NO_EXCEPTIONS in it. There should be some conditions around the #define to help explain when Boost defines it. You may be able to configure your build to avoid the definition and get past the linker error you're experiencing.
If you're unable to change your compiler config to avoid the definition, then you're probably left defining boost::throw_exception(std::exception const & e) yourself somewhere in the OpenOffice code. I'm unfamiliar with that code, though, so I can't give a good suggestion where it should go.
Related
I am using the checkerFramework gradle plugin to statically analyze nullness and tainting in my code. When I run the checker via gradle, only one of my classes are properly checked. All the other classes return with the ambiguous error about the checker not running:
error: [type.checking.not.run] NullnessChecker did not run because of a previous error issued by ja
vac
public class Main {
^
The manual linked does not metion what potentially causes this. I had some #Nullable annotations prepended to some static instance variables of the primary class I am using, but undoing those did not fix the issue.
My build.gradle is set up like so:
plugins {
// Checker Framework pluggable type-checking
id 'org.checkerframework' version '0.6.3'
}
checkerFramework {
checkers = [
'org.checkerframework.checker.nullness.NullnessChecker',
'org.checkerframework.checker.tainting.TaintingChecker'
]
}
apply plugin: 'org.checkerframework'
Where do I find more detail on this error?
You didn't show the full javac output. The relevant errors should be just above the error: [type.checking.not.run] line that you did show.
The Checker Framework runs as a plugin to javac. When javac issues an error in one class (including any Checker Framework error), javac may or may not process other classes. Unfortunately, there is no good way for a user to predict how far javac will get. Your best bet is to focus on the code that matters most to you, and resolve each error in turn before proceeding to other classes.
I am attempting to use the LMDB C API with Cython.
I want to import the following definitions from the header file:
typedef struct MDB_env MDB_env;
int mdb_env_create(MDB_env **env);
So I created a .pxd file:
cdef extern from 'lmdb.h':
struct MDB_env:
pass
int mdb_env_create(MDB_env **env)
And I am using it in a Cython script:
cdef MDB_env *e
x = mdb_env_create(&e)
This code compiles fine, but If I run it, I get:
ImportError: /home/me/.cache/ipython/cython/_cython_magic_15705c11c6f56670efe6282cbabe4abc.cpython-36m-x86_64-linux-gnu.so: undefined symbol: mdb_env_create
This happens both in a Cython .pyx + .pxd setup and in a prototype typed in IPython.
If I import another symbol, say a constant, I can access it. So I seem to be looking at the right header file.
I don't see any discrepancy between my syntax and the documentation, but I am clearly doing something wrong. Can somebody give me a hint?
Thanks.
To compile it with IPythons-magic (would be nice if you would mention this explicitly in your question) you have to provide library-path (via -L-option) and library name (via -l-option) of the built c-library you want to wrap, see also the documentation:
%%cython -L=<path to your library> -l=<your_library>
The library you are trying to wrap is not a header-only library. That means that some symbols (e.g. mdb_env_create) are only declared but not defined in the header. When you build the library, the definitions of those symbols can be found in the resulting artifact, which should be provided to the linker when your extension is built. These definitions is what is needed when the program runs.
If you don't do it, the following happens on Linux: When the extension (the *.so-file) is built,the linker allows undefined symbols per default - so this step is "successful" - but the failure is only postponed. When the extension is loaded via import, Python loads the corresponding *.so with help of ldopen and in this step loader checks that the definitions of all symbols are known. But we didn't provide a definition of mdb_env_create so, the loader fails with
undefined symbol: mdb_env_create
It is differently for symbols which are defined in the header-file, for example enums MDB_FIRST&Co - the compiled library isn't necessary and thus the extension can be loaded, as there are no undefined symbols.
after a little code change inside a Store App I ran into a compilation error:
-> System.Void cannot be used from C# -- use typeof(void) to get the void type object.
Problem is: this comes from a generated file: XamlTypeInfo.g.cs.
case "System.Void"
userType= new ... ,typeof(global::System.Void), ...
...
Rolling back the changes did not help, as deleting bin & obj, restarting, etc.
Is the actual System.Void case entry maybe an indicator that something within a XAML file could not be recognized by the code generator? Is there an System.Void entry in a working XamlTypeInfo.g.cs?
--- ADDITION ---
I can now produce the compile error when changing specific lines. I have a custom control deriving from ItemsControl. I define a regular DP which works fine. I am also providing AttachedProperties for Template, TemplateSelector and Style. Think of a Textbox that gets an Label via an AttachedProperty and its not just a string but like HeaderedControls you can define a Template etc. for the Lable.
The Problem is related to the Get/Set Methods for the AttachedProp. When I either change the Getter return type to DataTemplate or I comment out the Setter fully then the compile error comes:
public static DataTemplate GetLabelTEmplate(UIElement element)
{
return (DataTemplate)element.GetValue(LabelTemplateProperty;
}
public static void SetLabelTemplate(UIElement element, object value)
{
element.SetValue(LabelTemplateProperty, value);
}
Any ideas would be highly appreciated.
Best regards
Gope
After filing a bug complaint with microsoft they pointed me to the problem: The setter's value cannot be of type object. This information is needed for the XamlTypeInfo generation so when I changed object to DataTemplate it compiled.
Although I haven't tried it yet, I believe object is fine for plain WPF, but for Win 8 Store apps this does result in an compilation Error. Funny stuff... :)
According to documentation (https://developers.google.com/closure/compiler/docs/api-tutorial3#externs), it seems the closure compiler should rename variables when no external declaration exists, including when using functions/variables from an external bit of code. The example they give is
function makeNoteDom(noteTitle, noteContent, noteContainer) {
// Create DOM structure to represent the note.
var headerElement = textDiv(noteTitle);
var contentElement = textDiv(noteContent);
...
}
where the textDiv function is declared in the global scope by a third-party lib of some sort. It says textDiv should be declared external to prevent renaming.
My question is - when I put this code or similar into the Closure Compiler without any extern declarations why is textDiv not renamed (which would break the code), as the documentation indicates?
The compiler assumes that calls to an undefined function are in fact calls to an external functions. Using the command line compiler, you can use --warning_level VERBOSE to have the compiler treat this condition as an error.
The Web Application is primarily built for demos and assumes this by default. While you can set a VERBOSE warning level, it will not change this functionality. See the Additional Web Service Options page for information on options. I've filed a bug report about this.
Due to the renaming algorithm for properties, undeclared properties will be renamed in a breaking way if that same property name isn't declared on an object in externs.
1. Compiled Assembly from JSC
I've compiled what is intended to be client-side JavaScript using the JScript compiler (jsc.exe) on the server side in an attempt to make something that can be tested from a unit testing project, and maybe even something that can be debugged on the server side.
The compiled file contains only functions as follows (just for example) and it compiles fine into BitField.exe. Notice, no wrapper class or package in the source code.
------ BEGIN FILE (BitField.js) -------
function BitField(){
this.values = [];
}
// more functions ...
------- END FILE -------
jsc /fast- /out:BitField.exe Bitfield.js
Results in a BitField.exe assembly.
Success! Well, kind of ....
2. Testing Assembly / Access Point?
Secondly I've created a test project (in C#) and referenced in the BitField.exe assembly successfully. (The type of project is irrelevant but I'm providing more description to paint a full picture.)
The problem seems to be: I cannot find the namespace or a point at which I can access the BitField functions inside the BitField.exe assembly from my C# test project. The assembly doesn't seem to be a "normal".
In other words I need in C#
using ???WHAT???
Note: I don't want to use JScript "extensions", meaning keywords that won't run client-side (in a web browser), for example, class, package etc because I want the code to be clean as possible for copy & paste back into client side script environment (Regardless said "clean" code compiles fine by jsc.exe without use of those extensions). When I try to wrap the functions in package and class it starts producing compile errors so that's another reason not to use them - because they appear to make me alter my code.
Any suggestions as to how I can use the functions of the compiled JScript assembly (by having it referenced into another assembly) when there are no explicit containers in it?
Update / Proof
.NET Reflector view
After playing around with it for a while, and trying various combinations of command-line switches for jsc.exe, I'm pretty sure that what you're trying to do won't work as you'd wish it to. If you try to compile a js file that contains functions into a .Net library assembly, you get an error:
BitField.js(1,1) : error JS1234: Only type and package definitions are allowed inside a library
But, there is hope, yet! Here's what I would do...
I would keep your "clean" BitField.js file just as it is, and then create a batch file that wraps it in a JScript class and writes it out to a "dirty" js file. It's pretty clean if you think of it as part of the compilation of the code into the DLL. The code to wrap the BitField.js into BitFieldClass.js would look like this:
merge-into-class.js
var fso = new ActiveXObject("Scripting.FileSystemObject");
var ForReading = 1;
var inputFile = fso.OpenTextFile("BitField.js",ForReading, false);
var outputFile = fso.CreateTextFile("BitFieldClass.js", true);
outputFile.write("class BitFieldClass{\n");
while (!inputFile.AtEndOfStream)
{
var textLine = inputFile.ReadLine();
outputFile.write (textLine + "\n");
}
outputFile.write("}");
outputFile.close();
Then the batch file to wrap it and compile it is really simple:
compile-js.bat
cscript merge-into-class.js
jsc /t:library /out:BitFieldClass.dll bitFieldClass.js
Of course, if you wanted to do multiple files, you'd have to parameterize things a bit, but hopefully this is enough to demonstrate the idea.