The following code won’t link. For fun, the set_mapsize and set_flags are both defined in the same file. Both for .h & .c, and the set_mapsize works just fine.
D:\Work\lightningdb-win\liblmdb\Release [master +10 ~5 -0 !]> &"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\b
in\amd64\dumpbin.exe" /EXPORTS .\mdb.obj
Microsoft (R) COFF/PE Dumper Version 11.00.50727.1
Copyright (C) Microsoft Corporation. All rights reserved.
sorry for succinctness, I was typing with child in my arms :)
i see that you call 'dumpbin /exports' but 'dumpbin /symbols' will list all the symbols, so you can check whether there is anything similar to mdb_env_set_flags, or is it missing completely.
I ask about /GL flag, as it prevents using these flags.
hmm, markdown is messing up the formatting and stripping underscores. I understand that the symbol name in the obj file starts with the underscore, like _mdb_env_set_flags, without any additions (like @12)? In that case it all seems fine.
it's a long shot, but are you sure that set_mapsize is linked from the same obj file and not some other?
Maybe you have duplicate header files with different content? Check from where the header file is loaded for all projects.
Could it be that set_flags does contain as input types ifdefed types which do change the actual signature? That would make it possible to compile it but fail at link time because the library was compiled with a differen set of ifdefs.
The fact that both functions are defined in the same header doesn't mean they are implemented in the same library.
You need to find out on which *.lib file this function is implemented and reference it during the linking phase. The easiest (but ugliest) way of doing this is with a #pragma comment(lib, “xxx.lib”) on your *.c file
The "right" way would be to add the lib to your "Additional Dependencies" list on the project properties
Comment preview
Comments have been closed on this topic.
Markdown formatting
ESC to close
Markdown turns plain text formatting into fancy HTML formatting.
Phrase Emphasis
*italic* **bold**
_italic_ __bold__
Links
Inline:
An [example](http://url.com/ "Title")
Reference-style labels (titles are optional):
An [example][id]. Then, anywhere
else in the doc, define the link:
[id]: http://example.com/ "Title"
> Email-style angle brackets
> are used for blockquotes.
> > And, they can be nested.
> #### Headers in blockquotes
>
> * You can quote a list.
> * Etc.
Horizontal Rules
Three or more dashes or asterisks:
---
* * *
- - - -
Manual Line Breaks
End a line with two or more spaces:
Roses are red,
Violets are blue.
Fenced Code Blocks
Code blocks delimited by 3 or more backticks or tildas:
```
This is a preformatted
code block
```
Header IDs
Set the id of headings with {#<id>} at end of heading line:
## My Heading {#myheading}
Tables
Fruit |Color
---------|----------
Apples |Red
Pears |Green
Bananas |Yellow
Definition Lists
Term 1
: Definition 1
Term 2
: Definition 2
Footnotes
Body text with a footnote [^1]
[^1]: Footnote text here
Abbreviations
MDD <- will have title
*[MDD]: MarkdownDeep
FUTURE POSTS
RavenDB 7.1: Next-Gen Pagers - 5 days from now
RavenDB 7.1: Write modes - 7 days from now
RavenDB 7.1: Reclaiming disk space - 9 days from now
RavenDB 7.1: Shared Journals - 12 days from now
There are posts all the way to Feb 17, 2025
RECENT SERIES
Challenge
(77): 03 Feb 2025 - Giving file system developer ulcer
Answer
(13): 22 Jan 2025 - What does this code do?
Comments
I never understood why the header-based link system is needed. .NET and Java don't need them either, and they work much better.
tobi, They are needed because this way, you could write a single pass compiler. It meant very little memory was needed to actually do the compilation
Maybe the pre-processor conditionaly stripps the definition away?
Eti, Nope, I made sure of that.
Does dumpbin show the correct symbol in corresponding obj file?
D:\Work\lightningdb-win\liblmdb\Release [master +10 ~5 -0 !]> &"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\b in\amd64\dumpbin.exe" /EXPORTS .\mdb.obj Microsoft (R) COFF/PE Dumper Version 11.00.50727.1 Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file .\mdb.obj
File Type: ANONYMOUS OBJECT D:\Work\lightningdb-win\liblmdb\Release [master +10 ~5 -0 !]>
are you building with /GL option? also, try /SYMBOLS instead of /EXPORTS.
zdeslav, I am looking at you now with glazed eyes. No idea what you are talking about.
sorry for succinctness, I was typing with child in my arms :)
i see that you call 'dumpbin /exports' but 'dumpbin /symbols' will list all the symbols, so you can check whether there is anything similar to mdb_env_set_flags, or is it missing completely.
I ask about /GL flag, as it prevents using these flags.
I removed /GL flag, and then used /symbols. The object has _mdb_env_set_flags in it.
hmm, markdown is messing up the formatting and stripping underscores. I understand that the symbol name in the obj file starts with the underscore, like
_mdb_env_set_flags
, without any additions (like @12)? In that case it all seems fine. it's a long shot, but are you sure thatset_mapsize
is linked from the same obj file and not some other?those (env, ....)
I'm guessing they should be (&env, ....)
Keith, No, that is already a pointer.
what do the 3 warnings say?
Maybe you have duplicate header files with different content? Check from where the header file is loaded for all projects. Could it be that set_flags does contain as input types ifdefed types which do change the actual signature? That would make it possible to compile it but fail at link time because the library was compiled with a differen set of ifdefs.
Not enough details in this post to even suggest what the real problem is since I can't see what the project includes.
You need to have midl.h and midl.c in the project. Are they included?
Kelly, That was mostly to vent. I work around that since I just needed to test something out. FWIW, this was in the lmdb-win project.
The missing symbol is prefixed with a "_" unlike your usage?
The fact that both functions are defined in the same header doesn't mean they are implemented in the same library.
You need to find out on which *.lib file this function is implemented and reference it during the linking phase. The easiest (but ugliest) way of doing this is with a #pragma comment(lib, “xxx.lib”) on your *.c file
The "right" way would be to add the lib to your "Additional Dependencies" list on the project properties
Comment preview