Please help me compilated and link my branch CopperSpice!

Discuss anything related to product development
Post Reply
Navadvipa Chandra d
Posts: 24
Joined: Sun Apr 19 2020 7:02 pm

Please help me compilated and link my branch CopperSpice!

Post by Navadvipa Chandra d »

My branch this - https://github.com/Navadvipa-Chandra-das/copperspice
My application this - https://github.com/Navadvipa-Chandra-das/PrabhupadaDictionary

But at the moment the assembly of Prabhupada Dictionary is not possible, because CopperSpice is not being assembled.
[3770/3845] Linking CXX shared library bin\libCsGui1.8.dll
FAILED: bin/libCsGui1.8.dll lib/libCsGui1.8.dll.a
cmd.exe /C "cd . && C:\mingw64\bin\c++.exe -Wa,-mbig-obj -O3 -DNDEBUG -Wl,--no-undefined -shared -o bin\libCsGui1.8.dll -Wl,--out-implib,lib\libCsGui1.8.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\CsGui.rsp && cd ."
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/gui/CMakeFiles/CsGui.dir/widgets/qmainwindow.cpp.obj:qmainwindow.cpp:(.text+0x3b94): undefined reference to `QPrabhupadaStorage::LoadObject(QObject*, QPrabhupadaStorageKind)'

collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Compilation of all CopperSpice files was successful, but the Cs Gui library cannot find the body of the QPrabhupadaStorage::LoadObject() function, although this function is present in the file QPrabhupada.cpp .

I am using GCC compiler 12.2.0 + LLVM/Clang/LLD/LLDB 16.0.0 + MinGW-w64 10.0.0 (UCRT) - release 5.
This compiler works well, although it throws a lot of warnings. Until I added my CsPrabhupada library to CopperSpice, everything was fine, and when I added CsPrabhupada, difficulties immediately began. The fact is that CsPrabhupada uses types from CsGui and CsSql, and so I randomly and by touch began to edit various CMakeLists.txt and *.cmake files, but I mostly just look at them and fix something by analogy. I do not know CMake subtleties. Please help me!

Thank You very much!

With best regards, Navadvipa Chandra das.
barbara
Posts: 447
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Please help me compilated and link my branch CopperSpice!

Post by barbara »

But at the moment the assembly of Prabhupada Dictionary is not possible, because CopperSpice is not being assembled.
( A ) We are not sure what this means since CS is not written in assembly, it is C++ code. You need to compile CopperSpice and then link with your application.

( B ) You have stated that all of the CS libraries build successfully but then said CsGui is not building. Can you clarify which one is correct?
I am using GCC compiler 12.2.0 + LLVM/Clang/LLD/LLDB 16.0.0 + MinGW-w64 10.0.0
( C ) This is very confusing since it would not make sense to build with GCC, Clang, and MinGW at the same time. You should choose one compiler unless you are building on different platforms. We strongly suggest using our CS MinGW-w64 build when compiling on Windows if you are not using MSVC. We also suggest using a version of GCC or clang which has been tested in our CI.

https://www.copperspice.com/docs/cs_overview/supported-platforms.html
Until I added my Prabhupada library to CopperSpice, everything was fine
( D ) This is not the correct approach and you should not embed your code in an existing CS library. If your code base adds some cool features it should be a new library. Just like CsSql links with CsCore, you will to link "MyNewLibrary" with the CS libraries it depends on.

If you trying to extend the functionality of an existing class in CS then inherit from that class and put your changes in the child class. Before you do this it would be good idea to ask, what functionality are you trying to add and why.
Prabhupada uses types from CsGui and CsSql
( E ) Then your library should just link with CsGui and CsSql. Again, you should not merge your code into either of these CS libraries.
So I randomly began to edit various CMakeLists.txt and *.cmake files . . . I do not know CMake
( F ) If you want to write build files you will need to learn CMake, at least a little bit. Randomly changing files is never a good approach, even for experienced programmers.

Figure out what you want to do and break it down to some very simple steps. Start by writing a user application which does just a few things, get that working first. Keep all the code in your user application. Then add more code to your application until everything is working. At this point you can decide if some of the functionality in your program is reuseable and should be moved to "MyNewLibrary".

Barbara
Navadvipa Chandra d
Posts: 24
Joined: Sun Apr 19 2020 7:02 pm

Re: Please help me compilated and link my branch CopperSpice!

Post by Navadvipa Chandra d »

Hello, Barbara and everyone else!

The Prabhupada Dictionary application is working. It is not fully written, but what is written is debugged and works. I agree that you need to make your own library. No, not everything can be divided without using the CopperSpice code. I just wanted to offer good things that not only me, but also other developers might need!

I managed to build CopperSpice with the CsPrabhupada library (another option), but when I started building my application, the program linker could not find my functions again, so I asked what I forgot to do to make the linker work correctly!

Thank you very much!
Sincerely, Navadvipa Chandra das.Thank you very much! Hare Krishna!
barbara
Posts: 447
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Please help me compilated and link my branch CopperSpice!

Post by barbara »

not everything can be divided without using the CopperSpice code
This is not correct and almost always indicates something about the design in your code is not valid. We suggest you back up and think about what you believe needed changing in CopperSpice. Discuss what you want to do and why. Let's talk about (a) here is what I want and (b) how do I implement this. Maybe all you need is a new Signal/Slot connection but it also might require inheriting a CS class to add some new functionality. There are very few user solutions with require altering the base CS classes.
I managed to build CopperSpice with the CsPrabhupada library (another option), but when I started building my application, the program linker could not find my functions
Your library should be a stand alone product and only link with the CopperSpice libraries. If you are doing anything else (which you indicated you are) this is probably incorrect.

Errors can show up at compile time or link time. This does not mean it is a linker bug or linker issue. The problem is always in your source code. To solve this, you will need to add debugging to your code and comment out various sections until you find which portion of your code is causing a problem. We understand this can be a lengthy process but that is what software development is all about.

Please keep in mind that If you submit your library for us to maintain then we will add the "Cs" prefix. We have done this before with another user. Until then you should remove this prefix since your library is not part of the CopperSpice project.

Barbara
Navadvipa Chandra d
Posts: 24
Joined: Sun Apr 19 2020 7:02 pm

Re: Please help me compilated and link my branch CopperSpice!

Post by Navadvipa Chandra d »

Thank You very much for letter!

I will remove the Cs prefix one of these days, since the CopperSpice compilation is a whole ceremony that stretches for a long time!
Now my Prabhupada library compiles well and at first glance stands on a par with such a library as, for example, CsSql. But when it comes to compiling a custom application, it turns out that it stands apart - apart from other Cs libraries.

These are the errors

Code: Select all

cmd.exe /C "cd . && C:\mingw64\bin\c++.exe -O3 -DNDEBUG -Wl,--no-undefined src/CMakeFiles/PrabhupadaDictionary.dir/PrabhupadaMain.cpp.obj src/CMakeFiles/PrabhupadaDictionary.dir/QPrabhupadaLoginWindow.cpp.obj src/CMakeFiles/PrabhupadaDictionary.dir/QPrabhupadaDictionaryWindow.cpp.obj src/CMakeFiles/PrabhupadaDictionary.dir/PrabhupadaUtil.cpp.obj src/CMakeFiles/PrabhupadaDictionary.dir/QPrabhupadaDictionary.cpp.obj src/CMakeFiles/PrabhupadaDictionary.dir/QPrabhupadaGoToLineWindow.cpp.obj src/CMakeFiles/PrabhupadaDictionary.dir/QPrabhupadaAboutWindow.cpp.obj src/CMakeFiles/PrabhupadaDictionary.dir/qrc_PrabhupadaDictionary.cpp.obj -o bin\PrabhupadaDictionary.exe -Wl,--out-implib,src\libPrabhupadaDictionary.dll.a -Wl,--major-image-version,0,--minor-image-version,0  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsSvg1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsXml1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsXmlPatterns1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsPrabhupada1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsMultimedia1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsWebKit1.8.dll.a  -lnetapi32  -lmpr  -mwindows  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsSql1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsOpenGL1.8.dll.a  -lopengl32  -lgdi32  -lkernel32  -luser32  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsGui1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsNetwork1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsScript1.8.dll.a  C:/CopperSpice/Lib/Release/1.8.0/lib/libCsCore1.8.dll.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/CMakeFiles/PrabhupadaDictionary.dir/PrabhupadaMain.cpp.obj:PrabhupadaMain:(.text.unlikely+0x10c): undefined reference to `QPrabhupadaStorage::~QPrabhupadaStorage()'
If you put the Prabhupada.h file and QPrabhupada.cpp in the Prabhupaddictionary application itself, everything worked well. I spent a lot of time writing the Prabhupaddictionary program in very small steps. Every step was debugged and perfected, at least as far as I could see.

I needed a convenient tool for saving windows when exiting the program and loading them when entering it. But I didn't want to use regular ini files. I have already used this format for saving settings in binary form to choose from - in a file, in a database and just in memory, so I wanted to create something similar in CopperSpice. I tried so that not a single field was added to any of the CopperSpice classes, which would increase memory consumption and reduce performance. But I have added some virtual functions. A couple of virtual functions cannot seriously damage the performance of CopperSpice. I saw two approaches of writing data to the QDataStream stream:
The first way is to write an external operator << or>>, for example

Code: Select all

inline QDataStream& operator >> ( QDataStream &ST, QPrabhupadaFindOptions &PrabhupadaFindOptions )
{
  return ST >> PrabhupadaFindOptions.m_CaseSensitive
            >> PrabhupadaFindOptions.m_RegularExpression
            >> PrabhupadaFindOptions.m_AutoPercentBegin
            >> PrabhupadaFindOptions.m_AutoPercentEnd;
}
But with this approach, it is impossible to call a chain of calls of this operator for all classes in the inheritance hierarchy! So I wrote to the data stream via a virtual function, for example:

Code: Select all

void QWidget::LoadFromStream( QDataStream &ST )
{
  QObject::LoadFromStream( ST );

  QByteArray BA;
  ST >> BA;
  restoreGeometry( BA );
}
void QMainWindow::LoadFromStream( QDataStream &ST )
{
  QWidget::LoadFromStream( ST );

  QByteArray BA;
  ST >> BA;
  restoreState( BA );
}
Also made a very interesting Pattern QPrabhupadaValue, which very elegantly replaces the concept of __property.
This is for searching for a simple occurrence of a word in a string, even when there are no special characters in the search bar. Therefore, I also added the Like() and LikeBest() functions to compare a string with a template, similar to how the LIKE operator works in SQL command SELECT. I think that such a function may well take its place in CsString - they do not ask to eat and do not pull the pocket. I haven't checked the performance of Likabest() yet. But I do not recommend the Like function, since it can quickly overflow the memory stack due to recursion.

If you manage to compile PrabhupadaDictionary, you can see everything with your own eyes. If not, I can demonstrate the work of PrabhupadaDictionary in a few days by transferring QPrabhupada.h and QPrabhupada.cpp in the local directory, at least to show the work of the PrabhupadaDictionary application itself.

Thank You very mach!

With best regards, Navadvipa Chandra das.
barbara
Posts: 447
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Please help me compilated and link my branch CopperSpice!

Post by barbara »

We have a few suggestions based on many years of programming experience. Keep in mind, the following are based on our opinion and other developers may offer you ideas you prefer.

1) Naming things like classes, variables, and even libraries is not simple and in fact can be really hard. If you are releasing something to a world wide audience you should use English. I know this can sound harsh but it is the accepted vernacular of the majority of users.

We did look up the word "Prabhupada" and it appears to be a proper name. This is a bad name and does not indicate to anyone what your library offers. When you see the name "CsNetwork" programmers can make a decent guess, this library will have something to do with network protocols.

2) You mentioned they code is not compiling and you are getting an "undefined reference". This is telling you there is a bug in your code. To resolve this you will need to go back and figure out what you did incorrectly according to the rules of C++. Creating a smaller program can often expose the problem.
A couple of virtual functions cannot seriously damage the performance of CopperSpice.
3) Nothing you are doing should require adding virtual functions to existing CS classes. That is not the intended purpose of this construct in C++. When you need additional functionality inherit from our CopperSpice class and then add new methods in your new class.

If you really believe something is missing in CopperSpice send us an email so we can discuss this in more detail. As another option, submit a pull request on github. The reason you really do not want to make changes to CopperSpice is about support. How will you integrate new changes our team has added? I am not discouraging you from maintaining your own fork of CS, but it can be a lot of work.
I needed a convenient tool for saving windows when exiting the program and loading them when entering it.
4) Are you trying to physically "save" a window? This would seem a bit odd. Did you simply want to save the size and position of the main application window? This is very common feature for an application. Please have a look at our Journal Example # 20.

https://journal.copperspice.com


Barbara
Navadvipa Chandra d
Posts: 24
Joined: Sun Apr 19 2020 7:02 pm

Re: Please help me compilated and link my branch CopperSpice!

Post by Navadvipa Chandra d »

Barbara, I don't really want to keep a separate fork of CopperSpice! I started it to put a requirement on GitHub, but since there were problems with the assembly of the Prabhupada library, I did not have time to do it.

Look here - the same Prabhupada.h and files QPrabhupada.cpp they work very well when built locally, but the PrabhupadaDictionary application is not built from the Prabhupada library. That's the problem.

That's what I wanted.
1. We hope that we have made a reliable and colorful QAirbus object!
2. Override two functions

Code: Select all

void QAirbus::LoadFromStream( QDataStream& ST )
{
  // 1
  // 2
  // 3
  ...
  // 108
}
void QAirbus::SaveToStream( QDataStream& ST )
{
  // 1
  // 2
  // 3
  ...
  // 108
}
3. Using an object of the class QStorage AStorage , we save the AAirbus in the Database

Code: Select all

AStorage SaveObject( AAirbus, QStorageKind::DB );
4. Restoring AAirbus from the

Code: Select all

AStorage.LoadObject( AAirbus, QStorageKind::DB );
That's it.

I knew about the existence of QSettings.

QSettings vs QStorage.

Disadvantages of QStorage:
1. When changing the structure of settings, all previous settings are subject to deletion. This happens when updating versions of the program.
2. It is quite difficult to edit the settings using external programs, such as a text editor and a database manager.

Disadvantages of QSettings :
1. Can work only with files
2. Stores all data in text format, even binary data.
3. Requires to create a unique string key for each portion of settings.
4. These disadvantages lead to slower loading and saving of settings. Moreover, as the size of the ini file grows, the speed of key-value search will fall all the time.

Advantages of QStorage:
1. Better performance.
2. No need to compose key names for portions of settings.
3. The ability to choose the storage location of settings - File, DB, Memory.

Advantages of QSettings
1. No need to delete all settings when changing the version of the program.
2. The ability to edit settings in a text editor.

Barbara, I tried to correct all your comments, except for leaving the name of the Prabhupada library.
I will prepare the SQL script for PostgreSQL later.

Anyone who is interested, please take a look at how Prabhupada's dictionary works (label version 2.0 on GitHub and label CopperSpice version 1.4 on GitHub)

And one more very very important question. How to avoid this error when compiling CopperSpice:

Code: Select all

-- Performing Test FILE64_OK
-- Performing Test FILE64_OK - Failed
-- Checking for 64-bit off_t - not present
-- Checking for fseeko/ftello
-- Performing Test FSEEKO_COMPILE_OK
-- Performing Test FSEEKO_COMPILE_OK - Failed
-- Checking for fseeko/ftello - not found
-- Large File support - not found
It seems that because of this error, the QFileStream class does not work in full.

Yes, and one more thing - I could not build CopperSpice using the mingw64_cs-10 compiler. CsSqlPsql plugin compilation error.
GCC 12.3.0 - did not try
And it would be good to fix CopperSpice and enable CMAKE_CXX_STANDARD 23. Would that be a bad thing?

Thank You very much!
With best regards, Navadvipa Chandra das.
barbara
Posts: 447
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Please help me compilated and link my branch CopperSpice!

Post by barbara »

Prabhupada.h and files QPrabhupada.cpp they work very well when built locally, but the PrabhupadaDictionary application is not built from the Prabhupada library. That's the problem.
The terminology "building locally" means to build on your computer. It is not clear what you mean by it worked and now it does not. It sounds like you tested one of your files and it worked but when you created a library it broke. That indicates you have a bug.

If you are able build your files in one project but not in another project, then you either have a build file issue or your code is not correct. As I have already mentioned, you will need to add some debugging code or break the project down into smaller parts. Since this is not an issue with our CopperSpice libraries our team can not tell the exact solution. If you want someone on our team to provide consulting services, this option is available.
Large File support - not found
This is a compiler feature, not defined by CopperSpice. This does not indicate that QFileStream is not working.
Do you really have files (with your settings) which are larger than 4 GB? This would seem really odd.
I could not build CopperSpice using the mingw64_cs-10 compiler. CsSqlPsql plugin compilation error.
We have zero issues using our MinGW 10 compiler on Windows. A new pre-built version for CS 1.8.2 was released just yesterday.

When we hear about issues like this it is almost always caused by multiple installation of complies and incorrect PATH settings on your system. You need to review and fix your system path and your bash profile.
And it would be good to fix CopperSpice and enable CMAKE_CXX_STANDARD 23. Would that be a bad thing?
We are currently using C++17 and will migrate to C++20 shortly. C++23 is way too new and most companies are not able to make this move. Some companies are just starting to use C++11, which is stunning but very common. Yes, rushing to newer version is not a good idea and it would hurt more developers than it would help.

Barbara
Post Reply