Solomon was also violating the First Commandment. There are stories that he had this occult "ring" through which he had power over a demon (or some demons) that he used to build the temple. I do believe that many of those ancient megalithic structures that would be impossible to build even with our modern technology were constructed with the aid of demons ... and their motivation would be clear, as the vast majority of these structures were temples for the worship of false (demonic) gods.
I believe such stories are from occult Jєωιѕн and Islamic sources. Would the Lord give Solomon instructions on how to build the Temple without providing him the means of building it? After all, the Lord did grant Solomon the gift of wisdom. Unfortunately, as time goes by, it seems that Solomon began losing it by marrying foreign women.
Note also I Kings 9:
And the Lord said to him: I have heard thy prayer and thy supplication, which thou hast made before me: I have sanctified this house, which thou hast built, to put my name there for ever, and my eyes and my heart shall be there always. [4] And if thou wilt walk before me, as thy father walked, in simplicity of heart, and in uprightness: and wilt do all that I have commanded thee, and wilt keep my ordinances and my judgments, [5] I will establish the throne of thy kingdom over Israel for ever, as I promised David thy father, saying: There shall not fail a man of thy race upon the throne of Israel. [6] But if you and your children revolting shall turn away from following me, and will not keep my commandments, and my ceremonies, which I have set before you, but will go and worship strange gods, and adore them: [7] I will take away Israel from the face of the land which I have given them; and the temple which I have sanctified to my name, I will cast out of my sight; and Israel shall be a proverb, and a byword among all people.